<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Yugabdh on Medium]]></title>
        <description><![CDATA[Stories by Yugabdh on Medium]]></description>
        <link>https://medium.com/@yugabdh?source=rss-972f50f3d215------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*edtId8uy-I89KRcYFLQJSg.png</url>
            <title>Stories by Yugabdh on Medium</title>
            <link>https://medium.com/@yugabdh?source=rss-972f50f3d215------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 12:53:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yugabdh/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Service Discovery for Microservices: Patterns, Best Practices, and Production Tips, Eureka]]></title>
            <link>https://medium.com/@yugabdh/service-discovery-for-microservices-patterns-best-practices-and-production-tips-eureka-effa81e39901?source=rss-972f50f3d215------2</link>
            <guid isPermaLink="false">https://medium.com/p/effa81e39901</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[service-discovery]]></category>
            <category><![CDATA[java-spring-boot]]></category>
            <category><![CDATA[netflix-eureka]]></category>
            <dc:creator><![CDATA[Yugabdh]]></dc:creator>
            <pubDate>Sun, 23 Nov 2025 07:14:50 GMT</pubDate>
            <atom:updated>2025-11-23T07:14:50.332Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><h3>What is service discovery?</h3><p>Service discovery is the process by which services locate each other and communicate without requiring hard-coded addresses.</p><h3>What is the need for service discovery?</h3><p>In a microservice-based application each service can have multiple instances. Instances run on virtualized or containerized environments. In such environments the number of instances and their location can change dynamically. Configuring or maintaining where each service lives becomes impractical.</p><blockquote>So, the problem that service discovery solves is -</blockquote><blockquote><strong><em>How does the client or another service — discover the location of a required service instance?</em></strong></blockquote><h3>What service discovery does?</h3><p>Service discovery provides registration and lookup and often a health check logic.</p><ul><li><strong>Registration: </strong>Each service instance registers itself with a central directory, or the infrastructure registers it automatically. While registering it typically provides id or name, address and port number.</li><li><strong>Lookup: </strong>When another service or client or gateway wants to communicate with registered service, it first queries the central directory. The central directory provides the location for communication from available instances.</li><li><strong>Health check: </strong>Often called heartbeat. If an instance of services goes down, the central repository needs an update to discard its details from it or mark it unreachable.</li></ul><h3>Types of service discovery</h3><p>There are two ways to have service discovery:</p><h3>Server-side discovery</h3><p>One liner — A load balancer or proxy queries the registry, and clients simply send requests to the proxy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*J19LCZlAJb3K_wui_VYnFA.png" /></figure><p>When making a request to a service, the client makes a request through router or gateway or load balancer that runs at a well-known location. The router queries a service registry, which might be built into the router, and forwards the request to an available service instance.</p><h3>Approaches</h3><h4>Cloud Native Approach</h4><p>Cloud providers like AWS offer native services for hosting microservice-based architectures. Using these native services for routing and discovery offloads the scaling and maintenance of those services to the cloud provider.</p><p>In AWS, a combination of ALB (Application Load Balancer) and internal DNS built-in VPC can be used for server-side service discovery.</p><p>ALB can forward HTTP requests to particular services by path-based, host-based matching for external traffic. While microservices can find each other inside the VPC using DNS. Or if services are managed and hosted using EKS (K8s), then we have Internal DNS (CoreDNS).</p><p>There are also services like AWS Cloud map for service discovery.</p><h4>Cloud-Agnostic Approach</h4><p>When are we supposed to go with this approach? When we have On-premises, hybrid cloud, or Kubernetes clusters where AWS services are not heavily used.</p><p>This means you don’t want to rely on a single cloud provider, because you may switch provider in future.</p><p>We can use modules like Spring Cloud API Gateway and Eureka for this approach.</p><p>API Gateway acts as a load balancer and router which does request forwarding based on routes. While the Eureka server acts as a service registry.</p><h3>Client-side discovery</h3><p>One liner — The client queries the service registry directly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*nyjKgobWRQIcRkL486-U3Q.png" /></figure><p>When making a request to a service, the client obtains the location of a service instance by querying a Service Registry, which knows the locations of all service instances.</p><p>This has fewer network hops compared to server-side discovery. Client needs to be enabled to query service registry. The client is responsible for performing load balancing.</p><p>Eureka can be used for both registry and discovery. Eureka provides Eureka Server which acts as a service registry and Eureka client which is used for registering current service with server and querying location of other services. There are options like Spring Cloud LoadBalancer which is used for client-side load balancing. Clients like RestTemplate or WebClient are already integrated with it.</p><p>Using client-side load balancing forces us to use cloud agnostic deployment style. We have to manage and scale our own Eureka server instances.</p><h3>Eureka</h3><p>Netflix Eureka is a Service Discovery and Registry solution. Beyond basic service discovery, Eureka offers seamless integration with other Spring Cloud components.</p><p>There are two key components:</p><h3>Eureka Server</h3><p><strong>Purpose:</strong> It allows microservices to register themselves at runtime and discover other services dynamically.</p><h3>Key Concepts</h3><ul><li><strong>Registry:</strong> Eureka Server maintains a registry of all client instances (metadata, host, port, status, etc.). Service registration happens on Eureka client startup. Eureka clients send metadata to Eureka Server to register itself.</li></ul><p><strong>Heartbeat:</strong></p><ul><li>Clients send periodic heartbeat requests to keep their registration active.</li><li>Default interval: 30 seconds.</li><li>If a client fails to send heartbeats for 90 seconds, it is removed from the registry.</li></ul><p><strong>Instance Info:</strong></p><ul><li><strong>status </strong>(UP, DOWN, OUT_OF_SERVICE)</li><li><strong>metadata </strong>(version, region, zone)</li></ul><p><strong>Replication:</strong></p><ul><li>Multiple Eureka Servers can replicate registry information between themselves.</li></ul><h3>Internal Working</h3><ol><li>Service starts =&gt; Registers itself with the Eureka Server via REST API (/eureka/apps).</li><li>Server adds service to registry.</li><li>Clients query the registry to discover other services (/eureka/apps/{serviceName}).</li><li>Heartbeats are sent periodically to maintain registration.</li><li>Server removes stale instances that don’t send heartbeats.</li></ol><h3>Modes of operation</h3><ul><li><strong>Standalone Mode: </strong>Only one Eureka Server. Simpler setup, but single point of failure.</li><li><strong>Cluster Mode: </strong>Multiple Eureka Servers replicate data with each other. Each server acts as both a server and a client to other servers.</li></ul><h3>What do we do in production?</h3><p>In the production environment Eureka server often operates in clustered mode. Where minimum 3–4 replicas of servers are running on K8s.</p><p>The Eureka server is typically secured at the network level using firewalls or a VPC, or it can be secured using basic authentication. Also, the traffic can be encrypted with HTTPs.</p><p>When basic authentication is set up each client has to authenticate before registering or querying Eureka.</p><h3>Additional Resources</h3><ul><li>Application properties: <a href="https://docs.spring.io/spring-cloud-netflix/reference/configprops.html">Configuration Properties :: Spring Cloud Netflix</a></li><li>Additional reads: <a href="https://microservices.io/tags/service%20discovery">microservices.io: service discovery</a></li><li>GitHub project: <a href="https://github.com/Yugabdh/eureka-server">Yugabdh/eureka-server</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=effa81e39901" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>