Skip to main content

Load Balancer Algorithm Simulator

Learn how different load balancing algorithms distribute traffic across servers. Experiment with Round Robin, Least Connections, IP Hash, and more. See how load balancers handle failures and optimize performance.

Category: Infrastructure

Topics covered: load-balancing, networking, educational, interactive, infrastructure

// simulator

Load Balancer Algorithm Simulator

Learn how different load balancing algorithms distribute traffic across servers. Experiment with Round Robin, Least Connections, IP Hash, and more. See how load balancers handle failures and optimize performance.

Supported byBecome a sponsor
BitriseAtomsizedDigitalOceanDevDojoSMTPfastQuizAPI
Load Balancer Simulator
0 successful
Server Failure Simulation:
Round Robin: Sends requests to each server in order: 1 → 2 → 3 → 1 → 2 → 3...💡 Click servers to toggle offline • No crash simulation
Users
Load
Balancer
Round Robin
Server 1
Server 2
Server 3
Server 1
0
requests handled
Server 2
0
requests handled
Server 3
0
requests handled

Understanding Load Balancing

What you'll learn

  • How different load balancing algorithms distribute traffic
  • When to use each algorithm based on your use case
  • How load balancers handle server failures
  • The difference between Layer 4 and Layer 7 load balancing
  • Impact of server weights on traffic distribution
  • Measuring distribution fairness and performance

Load balancing algorithms

  • Round Robin: Simple, even distribution for similar servers.
  • Least Connections: Best for long-lived connections.
  • IP Hash: Session persistence with sticky sessions.
  • Least Response Time: Optimal for varying performance.

Real-world applications

  • NGINX/HAProxy: Popular open-source load balancers supporting all algorithms.
  • AWS ELB: Application Load Balancer (Layer 7) vs Network Load Balancer (Layer 4).
  • Kubernetes: Service load balancing with kube-proxy using iptables/IPVS.
  • Cloudflare: Global load balancing with geographic routing and health checks.

Best practices

  • Use weighted algorithms when servers have different capacities.
  • Implement active health checks to detect failures quickly.
  • Consider geographic routing for global applications.
  • Use Layer 7 for content-based routing and SSL termination.
  • Monitor distribution fairness and server utilization.

Overview

A load balancer spreads incoming requests across several servers, and the algorithm it uses decides how even that spread is. This simulator sends a stream of requests to three servers and lets you compare four algorithms. Round robin sends each request to the next server in turn. Least connections sends it to the server with the fewest active requests, which helps when some requests take longer than others. IP hash sends the same client to the same server every time, which gives sticky sessions but can pile one network of clients onto one server. Random picks a server by chance. You can change the traffic rate from slow to burst, take servers out of service, set a failure rate and turn retries on or off, then watch how many requests each server handles and how many fail. The lesson is that no algorithm is best for every case: round robin is fine for uniform requests, least connections handles uneven work better, and session affinity is a trade-off you choose deliberately, ideally avoided by keeping sessions out of the server.

Try this

  1. Run round robin at the normal rate, then switch to least connections and compare how evenly the three servers are loaded.
  2. Take one server out of service and watch the load balancer route around it.
  3. Set the failure rate to high and toggle retries to see how many failed requests retries can save.

Frequently asked questions

What is the difference between round robin and least connections?
Round robin rotates through servers regardless of their load. Least connections picks the server with the fewest active requests, so it adapts when some requests take much longer than others.
What are sticky sessions?
Session affinity: the load balancer keeps sending a client to the same server, using a cookie or a hash of the client IP. It helps apps that keep session state in memory, at the cost of uneven load and harder failover.
Layer 4 or layer 7 load balancing: what is the difference?
A layer 4 load balancer routes TCP or UDP connections by address and port. A layer 7 load balancer understands HTTP, so it can route by host, path or header, terminate TLS and retry individual requests.

Try next

Sponsored
Carbon Ads
$ cd /games
// share