How Servers Find Each Other: DNS and Service Discovery
Explore how servers communicate in cloud environments through Public DNS, Private DNS, and modern Service Discovery mechanisms.

Stock photo for illustration only, not from the actual event
- Servers inside cloud datacenters can communicate without touching the public internet.
- DNS translates human-readable domain names into IP addresses for computer networking.
- Private DNS secures internal company directories away from the public internet.
- Service Discovery acts as an air traffic control system for managing microservice instances.
Communication between a web server and a database such as PostgreSQL inside AWS, Azure, GCP, or a private datacenter does not require crossing the public internet. A fundamental question that backend developers eventually encounter is how these servers discover each other's locations. Because servers are not human, this discovery challenge led to the evolution of distributed systems architecture.
Just as humans memorize names like city-hospital.com instead of GPS coordinates like 104.22.18.150, computers rely on the Domain Name System (DNS). The core job of DNS is mapping names to IP addresses. When a user visits a website, the computer queries DNS to retrieve the corresponding IP address before any connection can be established, preventing the internet from becoming a massive spreadsheet of raw IP numbers.
From an architectural perspective, understanding name resolution and service discovery is vital for building highly available systems. Hardcoding IP addresses in modern dynamic environments introduces massive operational overhead and rigidity. Technologies like Private DNS and Service Discovery abstract away network topology changes, ensuring seamless scalability and resilience.
While public DNS serves public websites effectively, backend infrastructure components such as internal APIs, Redis, PostgreSQL, RabbitMQ, and Elasticsearch should never be exposed to the public internet. Organizations solve this by implementing Private DNS, functioning as an internal directory accessible only within a private network or VPC using internal domain names like db.internal or redis.internal, completely hidden from the outside world.
Imagine building an e-commerce platform where hardcoding IP addresses like 10.0.12.55 directly into application code creates an operational nightmare whenever infrastructure shifts. Service Discovery solves this challenge by shifting the paradigm from finding a specific machine to finding a dynamic service.

Stock photo for illustration only, not from the actual event
As applications transitioned into microservices architectures—spanning User Service, Order Service, Payment Service, and Notification Service—each service often runs multiple instances, such as payment-1 through payment-4. When User Service needs to reach Payment Service, hardcoding fails because the system must dynamically track who exists, their exact locations, and whether they are currently healthy.
Service Discovery functions much like an air traffic control system for software components. Instances register their addresses and health status, allowing callers to query the registry and route requests appropriately, a foundational pattern famously adopted by Netflix with Eureka.
Source: Dev.to
Found something wrong in this article? Report an issue with this article
Comments
Leave a Comment