Skip to content
Maglev: A Fast and Reliable Software Network Load Balancer 4 min

Daniel E. Eisenbud, Cheng Yi, Carlo Contavalli, Cody Smith, Roman Kononov, Eric Mann-Hielscher, Ardas Cilingiroglu, Bin Cheyney, Wentao Shang, Jinnah Dylan Hosein · NSDI 2016

Maglev: A Fast and Reliable Software Network Load Balancer

How Google balances nearly all of its incoming traffic in software on ordinary servers, and the Maglev hashing algorithm that makes backends take turns.

Read the original paper

Networking · Black Belt · Pro · 4 min read

Maglev: A Fast and Reliable Software Network Load Balancer

Every time you open a Google service, your request lands on one of a few addresses and somehow reaches one of thousands of servers. The machine that decides where to send each connection is a load balancer. For years the standard answer was a specialized hardware box. Hardware load balancers are expensive, hard to upgrade, and limited by what one box can handle. If traffic doubles, you need a bigger box, not just another one.

Maglev, described in 2016, is Google's replacement: a load balancer written in software and run on ordinary servers. It has been a critical part of Google's front end since 2008 and serves almost all of Google's incoming user traffic. The paper is a lesson in scale-out design, and it contains an elegant new hashing trick.

Maglev spreads traffic over many commodity machines with the router's equal-cost multipath, sends each connection to a backend using connection tracking plus a lookup table built by Maglev hashing, and lets replies bypass the balancer. Adding capacity means adding machines.

How a packet travels

Every Google service has one or more virtual IP addresses (VIPs). A VIP does not belong to one machine. It is served by many backends. Here is the path of a request:

  1. The user's packet reaches Google's edge router. All the Maglev machines announce the same VIP with the same cost, so the router uses equal-cost multipath (ECMP) to spread packets over them.
  2. A Maglev machine picks a backend for the packet, then wraps it in a GRE tunnel header and sends it on. The backend unwraps it and sees the original packet.
  3. The backend answers the user directly through the router. This is direct server return. Responses are usually larger than requests, so Maglev does not need to carry them.
Maglev's place in Google's front door. The router spreads packets over Maglev machines. A Maglev machine picks a backend for each connection and forwards the packet. Responses skip Maglev and return directly.

Keep reading with Pro

This paper is part of Pro. Pro and Architect open the full breakdown, with animated diagrams, interactive elements you can play with and a quiz. A few papers stay free to read in full.

Still to read

3 more sections, 1 more diagram and 2 interactive elements to play with

  • Keeping a connection on one backend
  • Maglev hashing: taking turns
  • Why it matters

Found this breakdown useful?

Share it with someone else wrestling with this paper.

Discussion0

Join the Discussion

Sign in to leave comments, reply to others, or like insights.

Sign In to ScaleDojo

No comments yet. Be the first to start the thread!

Enjoyed this? Get more like it.

New paper breakdowns, levels, and one concept worth knowing, straight to your inbox.

No spam, ever. Unsubscribe in one click.

Enjoyed this content?

Your support keeps us creating free resources

We put a lot of hours into researching and writing these guides. If it helped you, consider buying us a coffee. Every bit goes toward keeping ScaleDojo's content free and growing.

$

One-time payment via Stripe. ScaleDojo account required.