Fundamentals of Distributed Systems: Microservices, Clustering, Load Balancing, Service Registry, Configuration Center, Circuit Breaker, and API Gateway
This article introduces core concepts of distributed systems, covering microservices, clustering, remote invocation, load balancing algorithms, service registration and discovery, configuration management, circuit breaking, degradation strategies, and API gateways, providing a comprehensive overview for building resilient cloud-native applications.
01. Distributed System Fundamentals
1. Microservices
Reject large monolithic applications and split services based on business boundaries; each service is independently deployed and run.
2. Cluster, Distributed, Node
Cluster
Physical form that groups several servers together to implement the same business.
Distributed
A working mode.
A collection of independent computers that appear as a single system to users.
Distributes different business functions across locations.
Node
A single server within a cluster.
3. Remote Invocation
In a distributed system, services may reside on different hosts and inevitably need to call each other, which is called remote invocation.
Spring Cloud uses HTTP + JSON to perform remote calls.
4. Load Balancing
Service A calls Service B, which is deployed on multiple machines; A can send requests to any instance.
Load balancing distributes requests across servers to improve availability.
Load balancing algorithms:
Round Robin: requests are dispatched sequentially to available servers in a loop.
Least Connections: requests go to the server with the fewest active connections, suitable for long‑running requests.
Hash: selects a server based on a hash of the client’s IP address, useful when stateful sessions are required.
5. Service Registration, Discovery, and Registry
When Service A calls Services B and C, it may not know which servers host B or C or whether they are up; a registry solves this problem.
The registry knows which services are healthy, which are down, and records newly added services, allowing callers to obtain valid addresses without checking themselves.
Service registration: services report their IP and port to the registry.
Service discovery: mechanism to query the list of available microservices and their network addresses.
Registry: central store of each service’s address, handling registration and deregistration.
Health check: removes services that cannot be accessed for a prolonged period.
6. Configuration Center
Each service has many configuration items; updating one configuration must be synchronized to all services.
Services obtain their configuration from a configuration center, which automatically updates them.
7. Service Circuit Breaker and Degradation
Order scenario: a client creates an order, the order service calls the product service, which calls the inventory service; if the inventory service fails, the chain collapses.
Avalanche scenario:
First snowball: inventory service becomes unavailable, causing many pending requests.
Second snowball: product service waits for inventory responses and becomes blocked.
Third snowball: order service cannot get product information and becomes unavailable.
Fourth snowball: clients cannot place orders, retrying and further overwhelming the system.
Circuit breaker: set a timeout; if a service’s failure rate exceeds a threshold within a period, short‑circuit protection is enabled, returning default data instead of invoking the failing service.
Service degradation: non‑core services are degraded, e.g., returning null, throwing exceptions, or providing mock data.
8. API Gateway
Abstracts common functionalities required by microservices.
Provides load balancing, automatic circuit breaking, gray release, unified authentication, rate limiting, and logging statistics.
Wukong Talks Architecture
Explaining distributed systems and architecture through stories. Author of the "JVM Performance Tuning in Practice" column, open-source author of "Spring Cloud in Practice PassJava", and independently developed a PMP practice quiz mini-program.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.