CSE Roadmap

Common tier · about 3 hours · 9 parts

Part 2 of 9 · 1 min read

Why a fixed address is not enough

Servers come and go, so callers need a way to look up who is alive now.

Think of a delivery company that moves its drivers around all day. A customer cannot be given one driver's mobile number. The customer calls the depot, and the depot says who is free.

Servers behave like those drivers. The book "Understanding Distributed Systems" notes that the number of servers behind a balancer can be raised or lowered without clients noticing, and that cloud systems add and remove servers automatically as load changes. Each new server has a new address. Each removed one leaves a dead address behind.

A worked example. A checkout service runs on 3 servers in the morning and 9 at the evening peak, and each change adds or drops addresses.

  • A day with two scale-ups and two scale-downs changes the address list 4 times.
  • Add one failure and one deploy that replaces all servers, and the list changes many more times.
  • A file with hard-coded addresses would be out of date within hours.

Callers need a way to learn who exists right now.

Service discovery

Service discovery is the way a caller finds the current addresses of a service it wants to call.

Example: the order service asks "where is the payment service?" and receives three addresses that are alive now.

Read it as

Discovery turns a name that never changes ("payment") into addresses that change all the time.

Check yourself:

  • Why can a hard-coded list of addresses become wrong within hours?
  • What does a caller want when it asks a discovery system a question?