Microservices — Service Registration and Discovery with Netflix Eureka

In micro-service architecture, there could be ten to millions of services deployed, running and communicating independently. The problem of these type of architecture is that how to find all other service endpoints.

Let’s consider a chat application. Abstract service discovery is present in now days chat applications but we did not know until micro services came into picture. As an example, in any chat application list of registered / connected contacts are shown upon successful login. Then you will be able to communicate with any contact listed in your registry/client. It’s quite same context what netflix eureka does.

Netflix Eureka is a lookup server (also called a registry). All micro-services (Eureka clients) in the cluster register themselves to this server.There are other service discovery clients like Consul, Zookeeper etc, but we will be using Eureka in this article. Consul and Zookeeper will be covered in future articles.


1) Create the eureka server project

Create a spring boot application including the below changes to the pom.xml

2) Add spring cloud eureka support

To make our server an Eureka Server @EnableEurekaServer annotation is added.

3) Configure application.properties / application.yml

Update the below configurations in the server application

4) Start eureka server

Start the spring boot application. Use the below endpoint to view the eureka server dashboard.

NOTE : All endpoints (including Eureka server dashboard) and ports can be customized according to your requirement.

5) Create the eureka client project

Create a spring boot application including the below changes to the pom.xml

6) Create rest endpoint to retrieve client details from service registry

In order to make sure that we have a eureka client application,@EnableDiscoveryClient annotation is required. Spring will enable service discovery related functionality based on the annotation.

The above restful API is exposed to return the connected clients endpoint details from service registry based on the application name given.

7) Configure bootstrap.properties / bootstrap.yml

Update the below configurations in the client application

8) Start the eureka client

Start the spring boot application. highlighted in below can be seen, once the client is successfully registered in eureka server.

Also, refresh the eureka dash board to see the updated clients.

Lets invoke the rest API developed to check whether the above application details can be retrieved by giving the application name.

Further Testing

Step 1: Lets further test by registering another client in eureka server. for that we are going to run the same client with a change to application name and port.

Step 2 : The new client which is deployed recently “DISCOVERY-CLIENT-1” can be retrieved from the old client “DISCOVERY-CLIENT” without doing a deployment or change.

Explorer more : Full code @ GitHub.



Technology evangelist

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store