EasyπŸ‘€ 0-2 yearsπŸ‘€ 3-5 years 1 min read

How does a load balancer distribute traffic, and what algorithms are common?

Reviewed by Gurusankar M.

Asked inAmazonInfosysCognizantWipro
#load balancing#round robin#least connections#l4 l7#health checks
Report issue

⚑ Short Answer

A load balancer spreads requests across healthy backends and removes failed ones via health checks. Common algorithms: round-robin, least-connections, and consistent-hashing (sticky by key). L4 balances by TCP/IP (fast), L7 by HTTP content (path/host routing).

β˜•Coffee Chat Question

Concept Made Simple

β€œHow does a load balancer distribute traffic, and what algorithms are common?”

🧠Mind Map Answer

Remember It Faster

Round-robin→even rotation
Least-connections→to the least-busy backend
Hash/sticky→same client/key → same backend
L4 vs L7β†’TCP fast / HTTP content routing

πŸ”₯What If?

Think Beyond the Expected

Why are health checks essential to a load balancer?

Without them the LB keeps sending traffic to dead/unhealthy instances, so users get errors. Health checks let the LB detect failures and route only to healthy targets β€” the core of self-healing and zero-downtime deploys.

πŸ˜‚Real World

L7 load balancers (ALB/Nginx) do path/host routing and TLS termination; least-connections suits uneven request costs. Health checks + connection draining make deploys and failures invisible to users.

🎯Interviewer's Expectation

Keywords they're listening for:

βœ“ distribute + health checkβœ“ round-robin/least-conn/hashβœ“ L4 vs L7βœ“ sticky sessions trade-offβœ“ removes unhealthy

⚠️Common Mistakes

  • βœ—No/weak health checks
  • βœ—Sticky sessions defeating even distribution
  • βœ—Single LB as a SPOF

βœ…Best Practices

  • βœ“Health checks + connection draining
  • βœ“Pick the algorithm to match request cost
  • βœ“Run the LB redundantly

πŸ”Follow-up Questions

  • 1When do you need sticky sessions (and why avoid them)?
  • 2L4 vs L7 β€” trade-offs?
  • 3How does the LB itself avoid being a SPOF?

🧩Related Technologies

ALB/Nginxconsistent hashinghealth checks

Continue Learning with AI

Take this question deeper with your favourite AI assistant. Pick a depth, copy the prompt, or open it directly β€” AI is your learning companion, not a shortcut.

Plain-language foundations

I'm preparing for a software engineering interview and want to understand this from scratch, as a beginner.

Topic: Load Balancing (System Design)
Interview question: "How does a load balancer distribute traffic, and what algorithms are common?"

Please:
1. Explain the core idea in simple, plain language, using an everyday analogy.
2. Define any technical terms you use.
3. Walk through one small, concrete example.
4. Finish with a single sentence I can easily remember.

Keep the tone friendly and assume I'm new to this topic.

Was this answer helpful?

Support our platform by exploring our recommended products.

As an Amazon affiliate, purchases through these links may earn us a small commission β€” at no extra cost to you. It helps keep Full Stack Interview Guru free.

Related Questions