Skip to main content

Distributed Systems and Microservices

The primitives that keep many independent services acting like one coherent system: failure detection, discovery, consensus, and resilience patterns.

Service Discovery

In a system with a handful of services and a static IP address for each, one service can just hardcode where another one lives. That stops working the moment instances scale up and down, get rescheduled to different machines, or fail and get replaced — the exact address of "the orders service" is now constantly changing, and every caller needs a way to find the current, correct set of addresses without being redeployed every time it shifts. Service discovery is that mechanism: a way for services to find each other's current network location dynamically instead of by hardcoded configuration.

Consensus Algorithms

Consensus is the problem of getting multiple nodes to agree on a single value — even when some nodes might be slow, crash, or become unreachable — and having every node that does agree end up with the same answer. It sounds abstract, but it's the problem underneath several very concrete things covered elsewhere in this course: which replica becomes the new database leader, which node holds a distributed lock, what the current, authoritative state of a cluster's membership is.

Distributed Locking

A lock in a single process is easy: one piece of memory, one owner at a time, enforced by the operating system. A distributed lock solves the same problem — making sure only one actor can hold a resource at a time — across multiple independent machines that can't share memory and can't fully trust the network between them. It's the mechanism behind questions like "how do we make sure only one instance of this cron job actually runs" or "how do we stop two servers from both thinking they own this task."

Distributed Tracing

A single request in a microservices system rarely stays within one service — it might hit an API gateway, call three backend services, each of which queries its own database or calls another service in turn. When that request is slow, or fails, "which of these dozen hops was the problem?" is not a question logs on any one service can answer alone, because no single service's logs show the whole journey. Distributed tracing solves exactly this: it follows one request across every service it touches and reconstructs the full picture.