A Service Registry is a directory that keeps track of every running instance of every microservice and its network location so other services can find and call it.
Key Points: • Services register themselves with the registry on startup, typically including their host, port, and health status. • Instances send periodic heartbeats so the registry can detect and remove instances that have crashed or become unreachable. • Other services or a load balancer query the registry to discover available, healthy instances at request time instead of using hardcoded addresses. • A registry enables dynamic scaling, since new instances become discoverable automatically and removed instances stop receiving traffic. • Popular implementations include Netflix Eureka, HashiCorp Consul, and Kubernetes' built-in service discovery via DNS.
Example: When a new instance of an Inventory service starts, it registers itself with Eureka; the API Gateway then asks Eureka for a healthy Inventory instance instead of pointing at a fixed IP address, so the gateway keeps working even as instances scale up or down.
Interview Tip: A concise interview answer is:
"A Service Registry is a live directory of service instances and their locations, updated through registration and heartbeats. It lets clients or load balancers discover healthy instances dynamically instead of relying on hardcoded addresses, which is essential once instances scale up and down."