Service discovery maps logical service identities to current instances. Clients still need health, load balancing and connection-reuse policies.
Before you start
You should understand HTTP, database transactions and the difference between one process and independently failing services. Draw the participants and message direction before choosing a pattern. Include timeout, duplicate delivery and recovery in the model instead of considering only successful requests.
The practical goal is to reason through this situation: A client calls a logical inventory service rather than a hard-coded instance address. Read the walkthrough first, then try the interview exercise before opening its answer. The important part is explaining the decision and its consequences, rather than remembering a definition alone.
Step-by-step walkthrough
Step 1: Use logical identity
Avoid coding one instance address into the client contract.
Step 2: Refresh endpoints appropriately
Follow discovery, health and connection-lifetime rules.
Step 3: Handle replacement safely
Retry only eligible attempts within the remaining deadline.
Worked scenario
A client calls a logical inventory service rather than a hard-coded instance address.
Instance A is replaced by B while a client retains a cached address and connection. Discovery updates do not automatically repair every existing connection. The client needs a policy for stale connections, failed attempts and refreshed endpoints without replaying uncertain mutations indiscriminately.
Common mistake
Cached addresses can outlive failed or replaced instances.
Verify the behavior
Replace an instance during traffic and inspect recovery, connection reuse and duplicate-effect risk.
Interview exercise
Handle instance replacement.
Answer and reasoning
Refresh discovery according to the platform contract and retry only safe failed attempts within a deadline.
Continue learning
Compare the scenario with the Microservices interview questions and test your understanding with the Microservices MCQs. For terminology and implementation details, consult the reference material.