Eureka Client register with multiple Eureka server issue - microservices

In my case want to register one microservice with multiple Eureka server from different zone.
I have tried with putting:
defaultZone: http://192.168.207.24:9002/eureka/,http://192.168.207.24:9003/eureka/
but in this case eureka client is getting registered with second one not on both.

Related

Register on eureka server on a different machine

I have a microservice architecture in developement mode with an API Gateway running on localhost:8080, some services on localhost:8081...8084 and an eureka server on localhost:8761.
The services register with eureka and everything works fine on my local machine.
I'm trying to deploy the services to azure as single containers. So each service will end up with a unique url.
How can I tell my eureka clients (api gateway and services) where the eureka server is running?
No matter what I try, it will always try to find the eureka server at localhost:8761. These are my settings for the API gateway:
eureka:
instance:
instance-id: ${spring.application.name}:${random.uuid}
client:
service-url:
default-zone: ${EUREKA_HOST:http://localhost:8761}/eureka/
I always end up with this error:
How can I get the services to connect to a eureka server that runs on something like https://example.azurewebsites.net:8761 ? The variable EUREKA_HOST has the correct value since I can use it at other places without problem.

In Spring Boot Eureka Client How does eureka.client.service-url.defaultZone work and how to add new eureka server?

By default the property eureka.client.service-url.defaultZone value is http://localhost:8761/eureka.
However I noticed that directly accessing this url returns 404. But http://localhost:8761 loads eureka dashboard. Then how does a eureka client gets registered with eureka server, does it internally accesses only the host name, and path /eureka is there for semantic purpose only?
Since eureka.client.service-urlis a map, would like to know how to register another eureka server which is not a defaultZone.
/eureka is an actual path prefix. It returns a 404 error because it is not defined as a valid path on its own. Specific service paths are built from that prefix, e.g. /eureka/apps/yourapp1.
About using multiple zones, this may help:
eureka:
client:
region: region-1
service-url:
zone1: http://eureka01.foo:8761/eureka/
zone2: http://eureka02.foo:8761/eureka/
availability-zones:
region-1: zone1,zone2

Spring Cloud Eureka Server : how does Eureka server knows what microservices instances are up?

I am working on Spring cloud framework. So each of my microservices will have to register with Eureka server, so Eureka knows the unique id or the application name.
(1) I have to have more than one instance of same microservice to be registered with Eureka, How do I achieve that? Microservice is deployed in Cloud Foundry.
(2) When all those instances from same microservices are registered with Eureka, how does Eureka know which instances are active and which not? How often Eureak knows and how Eureka gets this information.
Each instance sends are heartbeat to the eureka server, by default every 30 seconds.

How can i load balance on two eureka server on two different Machines?

I am using Spring Boot and Eureka server for achieving scalability. I have two servers both contain one eureka server and multiple eureka clients.
I want to load balance the API calls b/w clients on one server to another server. lets if A wants to connect to B and B is not available on the local eureka than the eureka should check the client availability on peer eureka server and redirect if available.
I tried making both eureka servers peer of one another here is my configuration
But it is not checking availability on peer eureka server
spring.application.name=dfs-eureka-server
eureka.instance.hostname=192.168.3.63
eureka.client.serviceUrl.defaultZone:http://192.168.3.0:9080/eureka/
eureka.client.register-with-eureka=true
eureka.client.fetch-registry=false
eureka.server.renewal-percent-threshold=0.49
eureka.server.enableSelfPreservation=true
eureka.dashboard.path=/eurekaweb
second eureka server
spring.application.name=dfs-eureka-server
eureka.instance.hostname=192.168.3.0
eureka.instance.preferIpAddress=true
eureka.client.serviceUrl.defaultZone:http://192.168.3.63:9080/eureka/
eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true
eureka.server.renewal-percent-threshold=0.49
eureka.server.enableSelfPreservation=true
eureka.dashboard.path=/eurekaweb
eureka dashboard
dashboard 1
dashboard 1
please suggest.
keep the below properties common in both the eureka servers and verify.
eureka.instance.appname=eureka-cluster
eureka.client.fetch-registry=true
eureka.client.register-with-eureka=true

Microservices - What is the exact difference between service discovery and Service Gateway?

I read the articles like : What is the difference between an API-Gateway and an Edge Service?, but still not clear on what's the exact difference between the service discovery (say Eureka) and Service Gateway (Zuul) ? Any pointers?
The Services gateway (a.k.a. API gateway) is receiving requests from the clients. It is the (single) service that the clients see. But it doesn't know by itself how to do what the clients want so it must forward the request to another service. It inspects the URL and extracts the name of the service that will actually serve the request, the backend service. That backend service may be located on a different machine. It may have a dynamic address or port, that may change from time to time, from different reasons (nodes fail, new nodes are added to the network etc).
So, the gateway doesn't know where to forward the request. This is the job of the Service-discovery service (Eureka). Eureka knows on which node is located and at which address and port every service is listening for requests. The gateway is asking Eureka where it can find the backend service (by sending it only its name). After Eureka is responding, the gateway is forwarding the request to that address.
The differences is more understandable if you focus in responsabilities of both Zuul and Eureka. As you can see below each one has specific tasks. Thats the main differences.
API Gateway
In Api Gateway we have to register services with its URL and matching patterns
like this:
id: order-service
uri: http://localhost:9003/
predicates:
- Path=/order/**
But the problem here is we can have multiple instances on different ports. Like this
uri: http://localhost:9003/
uri: http://localhost:9004/
uri: http://localhost:9005/
In this case, a gateway will fail to route to other instances.
Service Discovery
In case of service discovery, we will have to register client services to service discovery (which is another service). Like this
eureka:
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://localhost:8761/eureka/
Now all clients will register to service discovery automatically so even if there are multiple instances service register will take care of it.
Service Gateway operates at Network layer 7 (HTTP) and Service discovery operates at Network Layer 4 to be precise.
Zuul works at Layer 7 and Eureka works at Layer 4
Please refer to Kong Gateway which provides a uniform solution

Resources