Showing posts with label Eureka. Show all posts
Showing posts with label Eureka. Show all posts

July 21, 2017

How Internally works Eureka connection pool? How to configure?

We can configure total connections Eureka, updating peerNodeTotalConnections property in the application.yml (default: eurkea peerNodeTotalConnections is 1000) in eureka application:

eureka:
    server:
       waitTimeInMsWhenSyncEmpty: 0
       peerNodeTotalConnections: 1000
       peerNodeTotalConnectionsPerHost: 500

Ref:
https://github.com/spring-cloud/spring-cloud-netflix/blob/master/spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerConfigBean.java
EurekaServerConfigBean :
private int peerNodeTotalConnections = 1000;
private int peerNodeTotalConnectionsPerHost = 500;

http://blog.abhijitsarkar.org/technical/netflix-eureka/:
For Eureka server config: org.springframework.cloud.netflix.eureka.server.EurekaServerConfigBean that implements com.netflix.eureka.EurekaServerConfig. All properties are prefixed by eureka.server.
Further more info:
We can check eureka health and info, we can configure below configuration in Eureka:

instance:
    hostname: ${vcap.application.uris[0]:localhost}
    statusPageUrl: https://${eureka.hostname}/info
    healthCheckUrl: https://${eureka.hostname}/health
    homePageUrl: https://${eureka.hostname}/

For Eureka instance config: org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean that implements (indirectly) com.netflix.appinfo.EurekaInstanceConfig. All properties are prefixed by eureka.instance.

For Eureka client config: org.springframework.cloud.netflix.eureka.EurekaClientConfigBean that implements com.netflix.discovery.EurekaClientConfig. All properties are prefixed by eureka.client.

We can check eureka apps info:
https://github.com/Netflix/eureka/wiki/Eureka-REST-operations
Using ribbon, zuul configurations, we can manage connection pool also.


For more information about eureka connections:
DefaultEurekaServerConfig side maximum limit of Peer Node Total Connections = 1000 and Peer Node Total Connections Per Host = 500. DefaultEurekaClientConfig side it is 200 and 50.
Given our environment, from the short and medium-terms, the above default limits may be fine and these connections are not expensive as database connections
In the case in the long-term, we need to override the defaults, we have options to do so.
https://github.com/Netflix/eureka/wiki/Overriding-Default-Configurations
The life cycle of Eureka client and server are summarized below.
Registration:
Eureka client registers the information about the running instance to the Eureka server
Renewal:
1. Eureka client needs to renew the lease by sending heartbeats every 30 seconds.
2. The renewal informs the Eureka server that the instance is still alive. If the server doesn’t see a renewal for 90 seconds, it removes the instance out of its registry.
Fetching Registry:
1. Eureka clients fetch the registry information from the server and cache it locally. After that, the clients use that information to find other services.
2. This information is updated periodically (every 30 seconds) by getting the delta updates between the last fetch cycle and the current one.
3. After getting the deltas, Eureka client reconciles the information with the server by comparing the instance counts returned by the server and if the information does not match for some reason, the whole registry information is fetched again.
4. Eureka server caches the payload of the deltas, whole registry and also per application
Cancellation:
1. Eureka client sends a cancel request to Eureka server on shutdown.
2. This removes the instance from the server's instance registry thereby effectively taking the instance out of traffic.
Time lag:
1. All operations from Eureka client may take some time to reflect in the Eureka servers and subsequently in other Eureka clients.
2. This is because of the caching of the payload on the Eureka server which is refreshed periodically to reflect new information.

3. Eureka clients also fetch deltas periodically. Hence, it may take up to 2 minutes for changes to propagate to all Eureka clients.
Other ways:
Ribbon Configuration ref:
https://github.com/Netflix/ribbon/blob/3a707ec518a896053be44266dddc4c4f925f4e60/ribbon-core/src/main/java/com/netflix/client/config/DefaultClientConfigImpl.java#L331


More refference links:
Eureka default configuration:
https://github.com/Netflix/eureka/blob/master/eureka-client/src/main/java/com/netflix/discovery/EurekaClientConfig.java

https://github.com/Netflix/eureka/blob/master/eureka-client/src/main/java/com/netflix/discovery/DefaultEurekaClientConfig.java

https://github.com/Netflix/eureka/blob/master/eureka-client/src/main/java/com/netflix/appinfo/MyDataCenterInstanceConfig.java

https://github.com/Netflix/eureka/blob/master/eureka-core/src/main/java/com/netflix/eureka/DefaultEurekaServerConfig.java

https://www.npmjs.com/package/eureka-js-client

http://programtalk.com/java-api-usage-examples/com.netflix.discovery.DefaultEurekaClientConfig/

https://insight.io/github.com/Netflix/eureka/blob/master/eureka-client/src/main/java/com/netflix/appinfo/DataCenterInfo.java

https://spring.io/blog/2015/01/20/microservice-registration-and-discovery-with-spring-cloud-and-netflix-s-eureka


Read more ...

My Favorite Site's List

#update below script more than 500 posts