Modern traffic-intense websites should be able to handle hundreds of thousands, or even millions of simultaneous requests from users and clients and display correct images, texts, video or application data, staying quick and responsive. In order to deal with a high volume of traffic, you need to apply the best practices available and attract more servers.
This is where a load balanced will come in handy. What is a load balancer and how it works? This is a hardware- or software-based solution that distributes the traffic over your servers and directs clients to the servers capable of fulfilling their requirements so that to improve speed and capacity utilization, and make sure that none of servers overworks. That boosts performance significantly. Even if a single server goes down, the load balancer will redirect traffic to functioning online servers. When you add a new server to the group of your servers, a load balancer will start to redirect requests to it.
Therefore, a load balancer has several functions:
- distributes visitors’ requests and network load across several servers in the most efficient manner;
- allows for flexibility to add ad remove servers according to your demands;
- guarantees a high availability and reliability by sending requests to working servers only.
Load Balancing Algorithms
Every algorithm of load balancing has its own advantages, and the choice of load balancing method should depend on your needs:
- Least Connections. A request is sent to the server with the smallest number of current connections to the visitors. To calculate which server has the least connections, a load balancer evaluates relative computing capacity of each server.
- Round Robin. Requests are distributes over servers sequentially.
- IP Hash. A client is connected to the closest server according to his IP address.
It’s not a secret that the information about user’s session is usually stored in the browser (for example, shopping carts). Changing the server that receives requests from a client in the middle of his or her session can lead to problems with performance and failure of transaction. This is why it’s important to make sure that the requests from a client are directed to one and the same server during the entire session. This is called “session persistence”.
Worthy load balancers guarantee session persistence. Another good example of session persistence is when an upstream server keeps the data requested by a user in its cache to improve performance. Changing servers can make this information disappear for some time, which can hurt performance and speed.
Dynamic Configuration of Server Groups
Some ever-changing application need servers to be added or deleted on a regular basis, for example, the environment of Amazon Elastic Compute Cloud (they make users pay only for computing capacity that’s actually used, and at the same time allow scaling up and down according to traffic spikes). Load balancers are very helpful in such environments, because you can dynamically remove or add servers from your group without affecting current connections.
Hardware vs. Software Load Balancing
There are two basic types of load balancers: software-based and hardware-based. Providers of hardware-based options use proprietary software on their own machines, and often apply specialized processors. In order to handle growing traffic on your website, you’ll need to purchase bigger machines from your vendor. Software solutions typically work on commodity software, which makes them very flexible. You can try software on the hardware that you choose, or in cloud environments.
in social networks