API / Microservices Design Patterns Interview Questions
What is the Service Registry and Discovery pattern — client-side versus server-side discovery?
The Service Registry is a database of network locations (host + port) for all running service instances, kept up-to-date by registration (at startup) and deregistration (at shutdown or failure). Service Discovery is the mechanism by which a service caller looks up the current location of a dependency at runtime, replacing hardcoded hostnames with dynamic lookups.
Two styles of service discovery:
Client-side discovery — the calling service queries the registry directly, receives a list of healthy instances, and performs its own load balancing (round-robin, random, least-connections).
// Spring Cloud / Netflix Eureka client-side discovery
@LoadBalanced // Ribbon intercepts and resolves via Eureka
RestTemplate restTemplate = new RestTemplate();
// Call by logical service name — Ribbon resolves to a real IP:port
String result = restTemplate.getForObject(
"http://inventory-service/api/stock/SKU-99", String.class);
Server-side discovery — the caller sends the request to a load balancer (AWS ALB, HAProxy, Nginx, Kubernetes Service). The load balancer queries the registry and forwards to a healthy instance. The caller needs no registry SDK.
| Aspect | Client-side | Server-side |
|---|---|---|
| Who queries the registry | The calling service (via SDK) | The load balancer |
| Client SDK dependency | Required (Eureka client, Ribbon) | Not required — any HTTP client works |
| Language support | Needs SDK for each language | Works for any language / protocol |
| Examples | Netflix Eureka + Ribbon, Consul + Fabio | Kubernetes Service + kube-proxy, AWS ALB + ECS |
Kubernetes uses server-side discovery natively: a Service resource provides a stable DNS name and VIP; kube-proxy (or iptables/IPVS) routes traffic to healthy pods via Endpoints, which are kept current by the Endpoints controller watching pod readiness probes.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
