Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eureka Server: How to achieve high availability

I'm new to spring cloud. I've read this doc and it says the client application must specify a service url:

eureka:   client:     serviceUrl:       defaultZone: http://localhost:8761/eureka/ 

But what if localhost:8761 goes down?

like image 278
Neo Avatar asked Jul 24 '16 07:07

Neo


People also ask

What happens if Eureka server is down?

During the start-up, the clients trigger a REST call with the Eureka server to self-register to the server's instance registry. When a graceful shutdown occurs after use, the clients trigger another REST call so that the server can wipe out all the data related to the caller.

Does Eureka server do load balancing?

Eureka is a REST based service that is primarily used in the AWS cloud for locating services for the purpose of load balancing and failover of middle-tier servers.

Can we use Eureka server in production?

On both Eureka instances you will be able to see all the registered microservices. Like this you can scale-up and have multiple server instances in a production environment.

What are the advantages of Eureka server?

Eureka Server is an application that holds the information about all client-service applications. Every Micro service will register into the Eureka server and Eureka server knows all the client applications running on each port and IP address. Eureka Server is also known as Discovery Server.


1 Answers

Eureka Discovery Server should be used in the Peer-Aware config mode in production setups. Check: http://cloud.spring.io/spring-cloud-static/spring-cloud.html#_peer_awareness

For instance your first eureka server instance will have config like this:

server:    port: 1111 eureka:    instance:       hostname: peer1    client:       serviceUrl:            defaultZone: http://peer2:1112/eureka/ 

..and second server instance like this:

server:    port: 1112 eureka:    instance:       hostname: peer2    client:       serviceUrl:            defaultZone: http://peer1:1111/eureka/ 

When Eureka server instances will boot up they will look for each other. All microservices will register with them automatically, so if one goes down the other server instance will be always there. On both Eureka instances you will be able to see all the registered microservices. Like this you can scale-up and have multiple server instances in a production environment.

Note: If you are trying this on a single system, dont forget to edit the /etc/hosts file:
127.0.0.1 peer1
127.0.0.1 peer2

like image 73
Gurneet Sethi Avatar answered Oct 11 '22 19:10

Gurneet Sethi