Load balancing in Web applications
Vivek Viswanathan
The content of this article aims to provide some methods for load balancing on your Web application server (cluster) groups. Cluster is a group of servers running simultaneously a Web application, the process of implementing this group link makes the server act as a single server when viewed from an external perspective. To balance server load, the system needs to distribute requests to different nodes within the server cluster, with the aim of optimizing system performance. This will give your network more performance, scalability - avoid falling into a shortage of network resources in a business or Web application.
High availability can be interpreted as redundancy. If a server cannot manage a request, can other servers in that cluster manage it? In a high-availability system, if a Web Server fails, another server takes over immediately to process the request.
Scalability (Scalability) is the ability of an application to support an increasing number of people. If it takes 10ms for an application to respond to a request, how long will it take for it to respond to 10,000 requests at once? Infinite scalability will allow it to respond to these requests in about 10ms. Scalability is a measure of a range of factors such as the number of concurrent users that a cluster can support and the time it takes to process a request.
There are two main methods for load balancing:
- DNS round rotation
- Use hardware load balancers
DNS round rotation
Most of you probably already know that the Domain Name Server (DNS) database maps host names to IP addresses.
When you enter a URL into a browser (such as www.quantrimang.com ), the browser sends a request to the DNS asking it to return the IP address of the site. This is called DNS lookup. After the Web browser has obtained the IP address for the site, it will contact the site with the IP address, and display the page you just requested. DNS servers often have an IP address mapped to a site name. In our own example, the site www.quantrimang.com maps into an IP address of 222.255.31.160 .
To load balance with DNS, the DNS server must maintain a number of different IP addresses for the same site name. Many IP addresses represent multiple machines in a cluster, all of which map to a logical site name. In our example, www.quantrimang.com can be configured on three servers in a cluster with the following IP addresses:
222.255.31.160
222.255.31.161
222.255.31.162
In this case, the DNS server is mapped as follows:
www.quantrimang.com 222.255.31.160
www.quantrimang.com 222.255.31.161
www.quantrimang.com 222.255.31.162
When the first request reaches the DNS server, it returns the IP address 222.255.31.160, the first machine. When there is a second request, it returns the second IP address: 222.255.31.161. Again, with the fourth request, the first IP address is repeated.
By using DNS loop rotation as above, all requests for a site are distributed equally to all machines in the cluster. Therefore, with this load balancing method, all nodes in the cluster are used.
Advantages of DNS round robin method
The main advantages of this method are that it is cheap and easy:
• Not expensive and easy to set up : System administrators only need to make some changes in the DNS server to support round robin, and many DNS servers have this support. It does not require changes to the Web application code; In fact, Web applications are unaware of the load balancing mechanism that it is performing.
• Simple : This method does not require network experts to set up or troubleshoot the system in case something happens.
Disadvantages of this method
There are two main drawbacks to this software-based approach: it does not provide real-time relationship support between servers and does not support high availability.
- Does not support real-time relationships between servers . The real-time relationship between servers is the system's ability to manage the requirements of this user, server or any server, depending on the session information maintained on the server or at the base level, database level.
Without the ability to support the relationship between servers, the DNS round-robin method relies on one of three methods that have been introduced to maintain session control or user identity for requests. is coming over HTTP.
- Cookies
- Hidden schools
- Rewrite the URL
When a user makes a first request, the Web server returns a single text tag to distinguish that user. Subsequent requests have this tag to use cookies, rewrite URLs, or hidden fields, allowing the server to appear to maintain a session between the client and the server. When a user establishes a session with a server, all incoming requests usually go to the same server.
The problem here is that the browser stores the IP address of that server. When the Cache expires, the browser will make another request to the DNS server to obtain the IP address associated with the domain name. If the DNS server returns another IP address, another server in the cluster, the session information will be lost.
- Does not support high availability . Consider a cluster with n nodes. If a node has a problem, every nth request to the DNS server will direct you to this broken node. A smart router can solve this problem by checking the nodes at certain intervals, detecting broken nodes and removing them from the list, so there is no requirement. Any more sent to them. However, the problem here still exists if the node is still there but the Web application running on the node has been corrupted.
Changing the cluster will take a long time to spread to the rest of the Internet. One reason is that in many large organizations - ISPs, companies, or agents - save their DNS requests to reduce network traffic and request time. When users within such organizations make a request, the system will check the list of Cache DNS names that have been mapped to the IP address. If the system detects an entry, it returns the IP address to the user. If it does not detect any entries in the internal Cache, the ISP sends this DNS request to the DNS server and saves the response.
When a saved entry expires, the ISP will upgrade its internal database by contacting other DNS servers. When your list of servers changes, it may take a short time for the entries saved on other organizations' networks to expire and search for the updated list of servers. During this cycle, the client can still perform a "hit" action on the broken server node, if that client's ISP still has an entry pointing to it. In such a case, some users of that ISP cannot access your site from the initial access, even if your cluster has redundant servers that are still active.
A bigger problem arises when removing one node from the addition. When you reduce a node, the user may be executing a 'hit' of a non-existent server. When you add a node, the server is not used until its IP address reaches all DNS servers.
Although this method can balance a number of users on each server, it does not completely balance server load. Some users may require higher load levels throughout their session than other users on another server, and this method cannot guarantee that unfairness.
Part II: Hardware-based load balancing
You should read it
- Balancing download of Exchange 2007 SP1 Hub Transport servers with Windows Network Load Balancing (Part 1)
- How to Enable Cross Origin Resource Sharing (CORS) for Sharing Resource Using Apache Servers, PHP and Jquery
- How to fix 408 Request Timeout error
- [Theory] What is Proxy Server?
- How to check for simple Linux server performance
- 5 reasons why you should avoid free proxy servers
- Blade Server - New server architecture
- 4 basic difference between Windows Server and Windows Desktop
May be interested
- How to fix Safari error can not load websites on Macever encountered the problem of not being able to load pages on safari on a mac? obviously your network connection is extremely stable, but a website can't keep loading on safari. here is how to fix this phenomenon.
- How to Ride a 'Hoverboard' (Two‐Wheeled Self‐Balancing Scooter)so you have a two-wheeled self-balancing scooter - now you want to learn how to ride it. its super easy to learn and even easier than learning to ride a full size segway! get started with step 1 and you'll be smooth sailing in no time....
- Operator overload and Load overlap in C ++c ++ allows you to define more than one definition for a function name or an operator in the scope, respectively called load overloading (function overloading) and load operator overloading in c ++. .
- Install Cherokee with PHP5 and MySQL supported in Fedora 14currently, cherokee is one of the lightest web server, high flexibility and easy to configure and set up. in addition, it also supports many advanced technology platforms such as fastcgi, scgi, php, cgi, encryption connecting tls and ssl protocols, virtual hosts, encryption mechanisms, load balancing of resources, data data of the system, apache log file ...
- Guide to speed up website loading in a simple wayaccording to kissmetrics, 47% of users expect a website to load in about 2 seconds, 40% of users will abandon a website if it takes more than 3 seconds to load.
- 5 useful applications for small business ownersare you an online business or a small business owner operating your business day and night? you will encounter difficulties in communicating, balancing life, accounting or some of the daily management issues that you do not have enough time to solve. the following 5 applications will be useful for you to solve that problem.
- How to fix Steam 'Failed to load steamui.dll' error on Windows 10how to fix failed to load steamui.dll error when opening steam on windows 10 operating system? share 6 ways to fix the failed to load steamui.dll error most effectively
- How to load Rules Of Survival card with phone scratch cardcurrently rules of survival can load game cards with phone scratch cards easily with support on vng system.
- How to load cards in the Rules Of Survival PC gameon the rules of survival: the survival law has released a new card-loading channel, making it easy for users to load cards via the in-game system.
- If you encounter a Firefox browser error: Could not load XPCOM, this is a fixthere are many causes of the 'couldn't load xpcom' error in firefox. the reason may be due to a windows update or an error in the firefox browser profile folder. the firefox browser profile folder has an error due to virus attack or after installing the 3rd extension on firefox browser.