What is service discovery in microservices?

Answer

Service discovery is the mechanism by which services in a microservices system find each other's network locations (IP address and port) without hard-coding them — especially important because services can scale up, move, or fail at any time. There are two patterns: Client-side discovery (e.g., Netflix Eureka) where the calling service queries a service registry itself and performs load balancing; and Server-side discovery (e.g., AWS ALB, Kubernetes Service) where the caller sends requests to a load balancer or proxy that looks up the registry and forwards the request. Service registries like Consul, Eureka, and etcd store the current network location of each service instance.