Why you need it

Two copies of the shop are meant to keep it up when one fails. But if a person puts both copies on the same server, one dead server takes both with it. With dozens of servers and hundreds of copies, nobody can keep track of where everything should go by hand.

Think of it like this

A host at a busy restaurant. You do not walk in and pick a table yourself. The host looks at which tables are free and big enough, and spreads big groups so one waiter is not swamped.

Where you’ll find it

  • Google: Borg places almost every Google program onto machines in its data centres, and spreads copies so one failure does not take them all.
  • Kubernetes: The kube-scheduler picks a server for every new container, skipping servers without room.
  • Amazon ECS and Nomad: Both choose servers for you: ECS task placement and Nomad's scheduler.

What to know first

Container. The app packed in a box with everything it needs, so it runs the same on any server. See Containers.

Copy. One running container of the app. Running two or more means one can fail while the others keep answering.

Cluster. A group of servers that are managed together, as one big pool of room.

How it works

  1. Ask for a copy, not a server. You say "run one more copy of the shop". You do not say where. Choosing the server is the scheduler's job. This is the scheduler in the animation.
  2. First, rule servers out. The scheduler drops every server that cannot take the copy: too little free memory or CPU, wrong kind of machine, or switched off. In the animation, server 1 is full, so it is skipped.
  3. Then, pick the best of the rest. Each server left gets a score. A server that already runs a copy of the shop scores lower, so copies spread out. That is why the scheduler puts the second copy on server 2.
  4. Spread across what can fail together. Servers in one rack or one building can go down together. Good schedulers spread copies across racks and zones too, not only across servers.
  5. Room is what was reserved. "Full" usually means the memory already promised to other containers, not what they use right now. See Requests and limits.

An example

Three servers, 8 GB of memory each. Server 1 has 1 GB free, servers 2 and 3 have 6 GB free. One shop copy already runs on server 3.

A new shop copy needs 2 GB. Server 1 is ruled out: not enough room. Server 3 scores lower: it already has a shop copy.

The copy goes on server 2. Now any one server can die and the shop stays up.

Further reading