Here is how to Increase the capacity of concurrent users on your site
Today we will see the main problem faced by most of the sites getting slow and sometimes crashed by the increase in numbers of users visiting simultaneously, to cope up with such kind of problem there is a reliable solution. “By using Load balancers” this may sound very costly effort for this problem but such huge users visit will provide you a lot of status and the most important increase in traffic generation.
So till now, we have the solution but now we will understand what the Load balancer is and why is it used for, in the practical perspective.
A load balancer is a device that acts as a reverse proxy and distributes network or application traffic across a number of servers. Load balancers are used to increase capacity (concurrent users) and reliability of applications. Load balancers ensure reliability and availability by monitoring the “health” of applications and only sending requests to servers and applications that can respond in a timely manner.
Roles:
•Distributes client requests or network load efficiently across multiple servers
•Ensures high availability and reliability by sending requests only to servers that are online
•Provides the flexibility to add or subtract servers as demand dictates
Now as the definition says that distributes traffic across a number of servers which indirectly indicates that it is useful for large applications. Let’s get into deep to understand the load balancer and load balancing.
Load balancers are generally grouped into two categories: Layer 4 and Layer 7. Layer 4 load balancers act upon data found in network and transport layer protocols (IP, TCP, FTP, UDP). Layer 7 load balancers distribute requests based upon data found in application layer protocols such as HTTP.
Requests are received by both types of load balancers and they are distributed to a particular server based on a configured algorithm. Some industry standard algorithms are:
•Round Robin – Requests are distributed across the group of servers sequentially.
•Least Connections – A new request is sent to the server with the fewest current connections to clients. The relative computing capacity of each server is factored into determining which one has the least connections.
•IP Hash – The IP address of the client is used to determine which server receives the request.Layer 7 load balancers can further distribute requests based on application specific data such as HTTP headers, cookies, or data within the application message itself, such as the value of a specific parameter.
Load Balancer works by using anyone of the above-mentioned algorithms lets see in detail one by one to understand the functionality of load balancer we need to understand the algorithms.
Round-robin load balancing: Round-robin load balancing is one of the simplest methods for distributing client requests across a group of servers. Going down the list of servers in the group, the round-robin load balancer forwards a client request to each server in turn. When it reaches the end of the list, the load balancer loops back and goes down the list again (sends the next request to the first listed server, the one after that to the second server, and so on).
The main benefit of round-robin load balancing is that it is extremely simple to implement. However, it does not always result in the most accurate or efficient distribution of traffic, because many round-robin load balancers assume that all servers are the same: currently up, currently handling the same load, and with the same storage and computing capacity. The following variants to the round-robin algorithm take additional factors into account and can result in better load balancing:
- Weighted round robin – A weight is assigned to each server based on criteria chosen by the site administrator; the most commonly used criterion is the server’s traffic-handling capacity. The higher the weight, the larger the proportion of client requests the server receives. If, for example, server A is assigned a weight of 3 and server B a weight of 1, the load balancer forwards 3 requests to server A for each 1 it sends to server B.
- Dynamic round robin – A weight is assigned to each server dynamically, based on real-time data about the server’s current load and idle capacity.
Flow chart for Round Robin Algorithm:
Least Connections: When a virtual server is configured to use the least connection load balancing algorithm (or method), it selects the service with the fewest active connections. This is the default method, because, in most circumstances, it provides the best performance.
For TCP, HTTP, HTTPS, and SSL_TCP services, the NetScaler appliance includes the following connection types in its list of existing connections:
Active connections to a service. Connections representing requests that a client has sent to the virtual server and that the virtual server has forwarded to a service. For HTTP and HTTPS services, active connections represent only those HTTP or HTTPS requests that have not yet received a response.
Waiting connections in the surge queue. Any connections to the virtual server that are waiting in a surge queue and have not yet been forwarded to a service. Connections can build up in the surge queue at any time, for any of the following reasons:
Your services have connection limits, and all services in your load balancing configuration are at that limit.
The surge protection feature is configured and has been activated by a surge in requests to the virtual server.
The load-balanced server has reached an internal limit and therefore does not open any new connections. (For example, an Apache server’s connection limit is reached.)
When a virtual server uses the least connection method, it considers the waiting connections as belonging to the specific service. Therefore, it does not open new connections to those services.
IP Hash: Source IP Hash load balancing uses an algorithm that takes the source and destination IP address of the client and server to generate a unique hash key. This key is used to allocate the client to a particular server. As the key can be regenerated if the session is broken, this method of load balancing can ensure that the client is directed to the same server that it was using previously. This is useful if it’s important that a client should connect to a session that is still active after a disconnection and reconnection.
Flow chart of IP Hash algorithm:
Since there are a lot of vendors who provide load balancers services but one can use these algorithms and create a virtual load balancer.
Hope this article would be helpful who are struggling with the site load issue they can create a virtual load balancer and reduce their cost and improve the performance.