Learn about Eureka Server of Netflix OSS

I have introduced you to Microservices and the great benefits that it brings. The process of building a Microservices-style application will be challenging and one of the challenges is how to manage the services that are being created, including maintenance, expansion, and high availability. The bigger application, the more difficult it will be, to manage these services.

To solve this problem, a concept called Service registration and discovery was introduced, which defines a server where services can be registered and managed.

This server will be responsible for storing and providing information about services in a Microservice system. When a service registers information with the server, it provides information such as its host, port, status. And it also sends regular heartbeat messages to inform the server of its status. Therefore, this server can easily provide information about services when they are called from other services.

Here are the basics of Eureka Server of Netflix OSS (Open Source Software) that I want to mention in this tutorial.

In this tutorial, I will guide you how to setup to be able to run a Eureka Server.

There are two ways to do this: The first is to use the .war file directly from Netflix, and the second is to use Spring Cloud Netflix.



Install Eureka Server using Netflix’s .war file

To get the .war file of the Eureka Server from Netflix, we have two ways:

The first way is to build it from source code.

The entire source code of Eureka Netflix is open source on Github here. Please clone this source code, then use Gradle to build the entire source code using the command:

Once you have finished, you can go to the eureka-server/build/libs/ directory to get the latest .war file. My current file name is eureka-server-1.8.9-SNAPSHOT.war.

The second is that I will download this file directly from the Remote Maven Repository as https://mvnrepository.com/artifact/com.netflix.eureka/eureka-server.

Currently, the latest version of Eureka Server is eureka-server-1.8.8.war.

Once you have the .war file of the Eureka Server finished, we can use the Java Server Runtime as Apache Tomcat, Jetty to deploy it.

I will use Apache Tomcat in this tutorial and build the .war file from the Eureka Server. After starting Apache Tomcat, I will access the Eureka Server with the following address:

http:// localhost:8080/eureka-server-1.8.9-SNAPSHOT/

Result:

Learn about Eureka Server of Netflix OSS

The “Instances currently registered with Eureka” section will contain information about all services registered with this Eureka Server. Since there are no services currently registered, you will not see anything here.


Install Eureka Server using Spring Cloud Netflix

Using Spring Cloud Netflix makes it easy to install Eureka Server. You only need to create a Spring Boot project with the Eureka Server dependency as follows:

Learn about Eureka Server of Netflix OSS

My result is as follows:

Learn about Eureka Server of Netflix OSS

Then, in the main class of our Spring Boot application, declare an annotation named @EnableEurekaServer as follows:

when running, the result will be:

Learn about Eureka Server of Netflix OSS

Looking at the above image, you can see, the information shown here is not much different than when we installed Eureka Server using the .war file from Netflix, do not you?

But there are some points to keep in mind when installing Eureka Server with Spring Cloud Netflix:

The default port of the Eureka Server is 8761 but here it is using the default port of the 8080 Tomcat.

We should configure the port to be the same as the default Eureka Server port by adding the server.port property to the application.properties application’s configuration file.

By default, the Eureka Server also acts as a service in a Microservices system.

Therefore, it also registers itself with Eureka Server and looks for information of other services, but the default Eureka Server address it registers is http://localhost:8761/eureka. Because this server does not exist, so if you check the console, you will see the following error:

We can fix these errors but we think it is not necessary. Being a Eureka Server, it should only serve as a place for other services to register and manage their information.

You can disable this default configuration by adding the following two properties to the configuration file of the application.properties application.

Then, restart the application, you will not see anything.

Learn about Eureka Server of Netflix OSS

Add Comment