Include the keyword “Eureka server” with
From this image, we can understand that both service providers and consumers need to communicate with the Eureka server. How do they exchange messages? Using a tool like Wireshark, you can clearly observe the communication information between them. The steps are as follows:
1: To allow Wireshark to capture packets from the local machine, which it cannot do by default, methods are described in this article.
2: Filter the captured packets using `src host local IP && dst host local IP`. The screenshot of the captured packets is as follows:
Include the keyword “Eureka server” with
From the image, we can intuitively gather at least two pieces of information:
- By default, the communication interval between a service provider and the Eureka Server is 30 seconds
- The API of the Eureka Server is designed in REST style. The main interfaces highlighted in the image are three, with request methods as GET, POST, and PUT, respectively.
GET Request Interface (Used to Obtain All Service Providers from the Registry)
The GET interface is used to request the currently available service providers from the registry, and the request URL is shown in the image below:
Include the keyword “Eureka server” with
The returned result is in JSON format, with data information as follows:
{ "applications": { "versions__delta": "1", "apps__hashcode": "UP_2_", "application": [ { "name": "CONSUMER", "instance": [ { "instanceId": "021ZJ1705.synacast.local:consumer:9000", "hostName": "10.200.121.41", "app": "CONSUMER", "ipAddr": "10.200.121.41", "status": "UP", "overriddenstatus": "UNKNOWN", "port": { "$": 9000, "@enabled": "true" }, "securePort": { "$": 443, "@enabled": "false" }, "countryId": 1, "dataCenterInfo": { "@class": "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo", "name": "MyOwn" }, "leaseInfo": { "renewalIntervalInSecs": 30, "durationInSecs": 90, "registrationTimestamp": 1530688491242, "lastRenewalTimestamp": 1530689331391, "evictionTimestamp": 0, "serviceUpTimestamp": 1530688490719 }, "metadata": { "management.port": "9000", "jmx.port": "64966" }, "homePageUrl": "http://10.200.121.41:9000/", "statusPageUrl": "http://10.200.121.41:9000/info", "healthCheckUrl": "http://10.200.121.41:9000/health", "vipAddress": "consumer", "secureVipAddress": "consumer", "isCoordinatingDiscoveryServer": "false", "lastUpdatedTimestamp": "1530688491242", "lastDirtyTimestamp": "1530688490594", "actionType": "ADDED" } ] }, { "name": "PROVIDER", "instance": [ { "instanceId": "021ZJ1705.synacast.local:provider:8000", "hostName": "10.200.121.41", "app": "PROVIDER", "ipAddr": "10.200.121.41", "status": "UP", "overriddenstatus": "UNKNOWN", "port": { "$": 8000, "@enabled": "true" }, "securePort": { "$": 443, "@enabled": "false" }, "countryId": 1, "dataCenterInfo": { "@class": "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo", "name": "MyOwn" }, "leaseInfo": { "renewalIntervalInSecs": 30, "durationInSecs": 90, "registrationTimestamp": 1530686242737, "lastRenewalTimestamp": 1530689333558, "evictionTimestamp": 0, "serviceUpTimestamp": 1530686242111 }, "metadata": { "management.port": "8000", "jmx.port": "63616" }, "homePageUrl": "http://10.200.121.41:8000/", "statusPageUrl": "http://10.200.121.41:8000/info", "healthCheckUrl": "http://10.200.121.41:8000/health", "vipAddress": "provider", "secureVipAddress": "provider", "isCoordinatingDiscoveryServer": "false", "lastUpdatedTimestamp": "1530686242737", "lastDirtyTimestamp": "1530686241987", "actionType": "ADDED" } ] } ] }}
Note: If the Eureka client requests all information about all service providers every time, it will put load stress on the Eureka Server. The Eureka server provides an incremental data fetching interface, shown in the following image:
Include the keyword “Eureka server” with
POST Request Interface
Used to submit the current service information to the Eureka Server. The request URL information is shown in the image below:
Include the keyword “Eureka server” with
The JSON structure submitted is as follows:
{ "instance": { "instanceId": "021ZJ1705.synacast.local:consumer:9000", "hostName": "10.200.121.41", "app": "CONSUMER", "ipAddr": "10.200.121.41", "status": "UP", "overriddenstatus": "UNKNOWN", "port": { "$": 9000, "@enabled": "true" }, "securePort": { "$": 443, "@enabled": "false" }, "countryId": 1, "dataCenterInfo": { "@class": "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo", "name": "MyOwn" }, "leaseInfo": { "renewalIntervalInSecs": 30, "durationInSecs": 90, "registrationTimestamp": 0, "lastRenewalTimestamp": 0, "evictionTimestamp": 0, "serviceUpTimestamp": 0 }, "metadata": { "management.port": "9000", "jmx.port": "64966" }, "homePageUrl": "http://10.200.121.41:9000/", "statusPageUrl": "http://10.200.121.41:9000/info", "healthCheckUrl": "http://10.200.121.41:9000/health", "vipAddress": "consumer", "secureVipAddress": "consumer", "isCoordinatingDiscoveryServer": "false", "lastUpdatedTimestamp": "1530688489595", "lastDirtyTimestamp": "1530688490594" }}
PUT Method Request
The PUT method request is used to maintain the heartbeat service between the service provider and the Eureka Server. The request information is shown in the image below:
Include the keyword “Eureka server” with
The request URL includes the application.name information, service URL, status information, and the last update time.