Skip to content
hostcomplex

Load Balancing Algorithms

Maarten Soetens 2 min read

What a Load Balancing Algorithm Decides

Load balancing algorithms are the rules a load balancer uses to choose a backend server for each new request or connection. The choice affects how evenly work is shared and how quickly users receive responses.

No single method suits every application. Some assume that all servers are identical and all requests take the same time. Others consider how busy each server is. Which method fits partly depends on the network layer the balancer works at, explained in layer 4 vs layer 7 load balancing.

Common Methods Compared

  • Round robin sends requests to each server in turn. It is simple and works well when servers are identical and requests cost about the same.
  • Weighted round robin gives stronger servers a larger share of requests. A machine with twice the capacity of another receives roughly twice the traffic.
  • Least connections sends each new request to the server with the fewest active connections. It suits workloads where some requests, such as large file uploads, keep a connection open much longer than others.
  • IP hash uses the client's IP address (its network address) to choose a server, so the same client usually reaches the same backend. This gives simple session stickiness, but many users behind one shared network address can all be sent to the same server.

Example: Mixed Server Sizes and Long Requests

Imagine a site with three servers, where one has more memory and CPU than the others. Round robin sends each server an equal number of requests, so the weaker servers may become overloaded while the strong one has spare capacity. Weighted round robin fixes this by sending that machine a larger share.

Now imagine that some requests are long video uploads. Round robin may place several uploads on the same server, which then slows down. Least connections notices which server is busy and sends new work elsewhere.

Frequently asked questions

Which load balancing algorithm is the best?

No single method is best for every case. Round robin is a sound default for identical servers with similar requests. Least connections suits long or uneven requests. Weighted methods suit servers of different sizes, and IP hash suits cases where the same client should keep reaching the same server.

What does a weighted load balancing method do?

A weighted method gives each server a number that represents its relative capacity, and servers with higher weights receive more requests. Administrators usually set weights based on the size of each machine. They can be adjusted when servers are upgraded or replaced.

Do load balancing algorithms handle failed servers?

Not directly. The algorithm chooses only among the servers the balancer currently considers healthy. Health checks remove failing servers from that list, so requests are not sent to them until they pass the check again.

  • Two-Factor Authentication

    Two factor authentication hosting adds a second check to control panel, domain and CMS logins. Learn which methods are strongest and why 2FA helps.

  • What Is an A Record?

    What is an A record? Learn how this DNS record maps a hostname to an IPv4 address, why domains use several A records and the root and www pattern.

  • Billing and Automation Platforms

    What is WHMCS? Learn how this commercial billing and automation platform helps hosts sell plans, collect payments and create accounts automatically.