How Server‑Side Service Discovery Simplifies Microservice Communication
This article explains how server‑side service discovery enables clients such as API gateways to locate dynamically changing microservice instances via a router or load balancer that queries a service registry, outlining requirements, solution architecture, examples like AWS ELB, benefits, drawbacks, and related patterns.
Background
In monolithic applications services call each other via language‑level methods. In traditional distributed deployments services run at fixed known host/port, allowing HTTP/REST or RPC calls. Modern microservices run in virtualized or container environments where instance counts and locations change dynamically.
Problem
How can a client—such as an API gateway or another service—discover the locations of server instances?
Requirements
Each service instance publishes a remote API at a specific host and port via HTTP/REST, Thrift, etc.
The number and location of instances change dynamically.
VMs and containers receive dynamic IP addresses.
Auto‑scaling groups adjust instance counts based on load.
Solution
When a client sends a request, it goes through a router or load balancer that queries a Service Registry and forwards the request to an available instance. The registry may be built into the router.
The diagram below illustrates this pattern.
Example
AWS Elastic Load Balancer (ELB) is an example of server‑side discovery. Clients send HTTP(S) or TCP requests to the ELB, which balances traffic across a set of EC2 instances. ELB can serve both external and internal traffic and can act as a Service Registry, with instances registering via API or auto‑scaling groups.
Cluster solutions such as Kubernetes or Marathon run an agent on each host to provide routing. Clients access a service through the port assigned to the local agent, which forwards requests to the appropriate instance.
Result
Server‑side discovery offers advantages:
Client code is simpler because it only needs to send requests to the router.
Some cloud environments provide this functionality out of the box (e.g., AWS ELB).
Drawbacks include:
Unless part of the cloud platform, the router must be installed and configured, requiring multiple replicas for availability.
It introduces additional network hops compared with client‑side discovery.
Related Patterns
Service Registry
Client‑side discovery as an alternative
Original source: http://microservices.io/patterns/server-side-discovery.html
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
ITFLY8 Architecture Home
ITFLY8 Architecture Home - focused on architecture knowledge sharing and exchange, covering project management and product design. Includes large-scale distributed website architecture (high performance, high availability, caching, message queues...), design patterns, architecture patterns, big data, project management (SCRUM, PMP, Prince2), product design, and more.
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.
