AWS, Azure & GCP · Cloud across providers

How do cloud load balancers work?

Mediumload balancinghigh availabilitynetworkingUpdated Oct 2026
Quiz this track

Short answer

A load balancer distributes traffic across healthy targets, terminates or passes through connections, and performs health checks. Layer 4 balances TCP and UDP; layer 7 routes HTTP by host, path or header.

A load balancer provides a stable endpoint in front of changing capacity. It removes unhealthy targets from rotation, spreads connections, and can handle TLS termination, redirects and routing rules. Managed services also scale the load balancer itself across zones.

What to consider

  • Layer 4 versus layer 7: TCP throughput and static IPs versus HTTP-aware routing
  • Health checks: path, interval, timeout and healthy threshold must match the app
  • TLS termination versus passthrough, and where certificates are managed
  • Sticky sessions when state is not externalised, and cross-zone load balancing
  • Idle timeout and connection draining during deploys
bash
aws elbv2 create-target-group   --name api-targets   --protocol HTTP   --port 8080   --vpc-id vpc-123   --health-check-path /healthz
A target group with an application health endpoint.

Health checks are only as good as the endpoint. A shallow TCP check can keep sending traffic to an app that cannot reach its database. A readiness endpoint should verify critical dependencies without becoming so strict that a transient blip removes every target.

Load balancers do not fix a stateful tier. If sessions live in instance memory, scaling or failover will lose them unless you use sticky sessions or externalise state.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1When would you choose a layer 4 load balancer over layer 7?
  2. 2How do you avoid health checks causing a cascading failure?
  3. 3What is connection draining and why does it matter during deploys?
  4. 4How do sticky sessions interact with autoscaling?

Say it in the interview

A load balancer gives me a stable endpoint and spreads traffic across healthy targets. Layer 4 is good for TCP and static IP requirements, while layer 7 supports HTTP routing, TLS termination and redirects. I pay close attention to health-check design, idle timeouts and connection draining, because those determine whether deploys and failures are graceful.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live AWS, Azure & GCP mock interview and get scored feedback on depth, clarity and confidence.