--- url: "http://microservices.io/patterns/service-registry.html" titulek: "Pattern: Service registry" h1: "Pattern: Service registry" popis: "" jazyk: "" kanonicka: "" drobecky: [] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-13 21:12:28" znaku: 8216 slov: 1031 kodovani: "utf-8" sha256: "b5a5ff622607d4c50d518069cdbdfc3d04c7625f969d0f0f52e85a007413eb59" --- #### [Microservice Architecture](/index.html) **Supported by [Kong](https://konghq.com/)** # Pattern: Service registry [pattern](/tags/pattern) [inter-service communication](/tags/inter-service communication) [service discovery](/tags/service discovery) --- ## Context Clients of a service use either [Client-side discovery](client-side-discovery.html) or [Server-side discovery](server-side-discovery.html) to determine the location of a service instance to which to send requests. ## Problem How do clients of a service (in the case of [Client-side discovery](client-side-discovery.html)) and/or routers (in the case of [Server-side discovery](server-side-discovery.html)) know about the available instances of a service? ## Forces - Each instance of a service exposes a remote API such as HTTP/REST, or Thrift etc. at a particular location (host and port) - The number of services instances and their locations changes dynamically. Virtual machines and containers are usually assigned a dynamic IP address. An EC2 Autoscaling Group, for example, adjusts the number of instances based on load. ## Solution Implement a service registry, which is a database of services, their instances and their locations. Service instances are registered with the service registry on startup and deregistered on shutdown. Client of the service and/or routers query the service registry to find the available instances of a service. A service registry might invoke a service instance’s [health check API](observability/health-check-api.html) to verify that it is able to handle requests ## Examples The [Microservices Example application](https://github.com/cer/microservices-examples) is an example of an application that uses client-side service discovery. It is written in Scala and uses Spring Boot and Spring Cloud as the [Microservice chassis](microservice-chassis.html). They provide various capabilities including a [Netflix Eureka](https://github.com/Netflix/eureka/wiki/Eureka-at-a-glance) service registry. The Eureka Server is a small Spring Boot application: ``` @SpringBootApplication @EnableEurekaServer public class EurekaServer { public static void main(String[] args) { new SpringApplicationBuilder(EurekaServer.class).web(true).run(args); } } ``` It is deployed using Docker: ``` eureka: image: java:openjdk-8u91-jdk working_dir: /app volumes: - ./eureka-server/build/libs:/app command: java -jar /app/eureka-server.jar --server.port=8761 ports: - "8761:8761" ``` Other examples of service registries (or technologies that are commonly used as service registries) include: - [Apache Zookeeper](http://zookeeper.apache.org) - [Consul](https://consul.io/) - [Etcd](https://github.com/coreos/etcd) Some systems such as Kubernetes, Marathon and AWS ELB have an implicit service registry. ## Resulting context The benefits of the Service Registry pattern include: - Client of the service and/or routers can discover the location of service instances. There are also some drawbacks: - Unless the service registry is built in to the infrastructure, it is yet another infrastructure component that must be setup, configured and managed. Moreover, the service registry is a critical system component. Although clients should cache data provided by the service registry, if the service registry fails that data will eventually become out of date. Consequently, the service registry must be highly available. You need to decide how service instances are registered with the service registry. There are two options: - [Self registration pattern](self-registration.html) - service instances register themselves. - [3rd party registration pattern](3rd-party-registration.html) - a 3rd party registers the service instances with the service registry. The clients of the service registry need to know the location(s) of the service registry instances. Service registry instances must be deployed on fixed and well known IP addresses. Clients are configured with those IP addresses. For example, [Netflix Eureka](https://github.com/Netflix/eureka/wiki/Configuring-Eureka-in-AWS-Cloud) service instances are typically deployed using elastic IP addresses. The available pool of Elastic IP addresses is configured using either a properties file or via DNS. When a Eureka instance starts up it consults the configuration to determine which available Elastic IP address to use. A Eureka client is also configured with the pool of Elastic IP addresses. - [Client-side discovery](client-side-discovery.html) and [Server-side discovery](server-side-discovery.html) create the need for a service registry - [Self registration](self-registration.html) and [3rd party registration](3rd-party-registration.html) are two different ways that service instances can be registered with the service registry - [Health Check API](observability/health-check-api.html) - the service registry invokes a service instance’s health check API to verify that it is able to handle requests --- [pattern](/tags/pattern) [inter-service communication](/tags/inter-service communication) [service discovery](/tags/service discovery) --- --- [Modernization Help](https://chrisrichardson.net/) Copyright © 2026 Chris Richardson • All rights reserved • Supported by [Kong](https://konghq.com/) . #### About Microservices.io Microservices.io is created by [Chris Richardson](/about.html), software architect, creator of the original CloudFoundry.com, and author of *Microservices Patterns*. Chris helps organizations modernize their architecture to enable fast flow and GenAI-powered software delivery. #### Need help modernizing your architecture? Avoid the trap of creating a modern legacy system — a new architecture with the same old problems. Contact me to discuss your modernization goals. [Get Help](https://www.linkedin.com/in/pojos/) #### Microservices Patterns, 2nd edition I am very excited to announce that the MEAP for the second edition of my book, Microservices Patterns is now available! [Learn more](/post/architecture/2025/06/26/announcing-meap-microservices-patterns-2nd-edition.html) #### ASK CHRIS ? Got a question about microservices? Fill in [this form](https://forms.gle/ppYDAF1JxHGec8Kn9). If I can, I'll write a blog post that answers your question. #### LEARN about microservices Chris offers numerous other resources for learning the microservice architecture. #### Get the book: Microservices Patterns Read Chris Richardson's book: --- #### Example microservices applications Want to see an example? Check out Chris Richardson's example applications. [See code](http://eventuate.io/exampleapps.html) #### Virtual bootcamp: Distributed data patterns in a microservice architecture My virtual bootcamp, distributed data patterns in a microservice architecture, is now open for enrollment! It covers the key distributed data management patterns including Saga, API Composition, and CQRS. It consists of video lectures, code labs, and a weekly ask-me-anything video conference repeated in multiple timezones. The regular price is $395/person but use coupon OFFEFKCW to sign up for $95 (valid until Sept 30th, 2025). There are deeper discounts for buying multiple seats. [Learn more](https://chrisrichardson.net/virtual-bootcamp-distributed-data-management.html) #### Learn how to create a service template and microservice chassis Take a look at my [Manning LiveProject](/post/patterns/2022/03/15/service-template-chassis-live-project.html) that teaches you how to develop a service template and microservice chassis. [Signup for the newsletter](http://visitor.r20.constantcontact.com/d.jsp?llr=ula8akwab&p=oi&m=1123470377332&sit=l6ktajjkb&f=15d9bba9-b33d-491f-b874-73a41bba8a76) #### BUILD microservices Ready to start using the microservice architecture? #### Consulting services [Engage Chris](http://www.chrisrichardson.net/consulting.html) to create a microservices adoption roadmap and help you define your microservice architecture, --- #### The Eventuate platform Use the [Eventuate.io platform](https://eventuate.io) to tackle distributed data management challenges in your microservices architecture. Eventuate is Chris's latest startup. It makes it easy to use the Saga pattern to manage transactions and the CQRS pattern to implement queries. --- Join the [microservices google group](https://groups.google.com/forum/#!forum/microservices)