API / Microservices Design Patterns Interview Questions
What is the Self Registration versus Third-Party Registration pattern for service discovery?
These two patterns describe how service instances get their network location recorded in (and removed from) the Service Registry — not how callers use it.
Self Registration — the service instance itself registers with the registry on startup and deregisters on orderly shutdown. It is also responsible for sending heartbeats so the registry can detect failed instances and remove stale entries.
- Example: A Spring Boot service with the Netflix Eureka client calls
eurekaClient.register()at startup andeurekaClient.deregister()in a shutdown hook. - Drawback: every service must import and configure the registry client library. The service is now coupled to the specific registry technology. If the registry changes, all services need updating.
Third-Party Registration — an external Registrar component monitors service instances (via the platform's event stream) and registers/deregisters them on their behalf. The service itself has zero registry awareness.
- Example (Kubernetes): The Endpoints controller watches pod events. When a pod passes its readiness probe, the controller adds its IP to the Endpoints resource for the corresponding Service. When the pod fails its probe or is deleted, the controller removes it. The pod never calls the registry directly.
- Example (Consul + Docker): A Registrator daemon on each host listens for Docker start/stop events and updates Consul accordingly.
| Aspect | Self Registration | Third-Party Registration |
|---|---|---|
| Coupling | Service coupled to registry client library | Service has no registry dependency |
| Complexity | Simpler — no extra component | Requires a Registrar / controller process |
| Language support | Needs SDK per language | Language-agnostic |
| Used by | Netflix Eureka, Consul client mode | Kubernetes, Consul + Registrator |
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...
