eureka
eureka copied to clipboard
Is there a notice function inside eureka while applications shutting down
I'm new in java, in recent days I'm trying to develop a graceful shut down script for my springboot applications, but this confused me a lot...
I have this little question while observing what will happen when I shut down one of my service application.
here is the structure of my testing applications:
- Eureka server service (E)
- one consumer serivce (A)
- two service provider service (B1 and B2) A calls B by feign client and returns which B is invoked(by using returning string 'service B at [it's port] is invoked').
I have found that no matter when I tried to shut down one of service B in a graceful way by spring boot acurator, there is a strange thing: I though this shut down instance will still be stay in eureka's instance list and also, in those applications' local cache because A and E may not have chance to reach the fetch or refresh time for new instance list after one of B was down.
So, in this case, I thought there might be a loadbalancer exception thown out because eureka client in A do not fetch a new instance list.
But what I observed was totally different from what I thought.
It seems to have a sneaky method to cancel the shutdown application's instance from eureka and notice all the applications which will call B for a downstream service immediately. All request will be send to B2 after a little time delay if I shut down B1 by sending /actuator/shutdown to B1.
Parent of the pom is:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
Here are my Eureka configuration: eureka server :
eureka:
server:
eviction-interval-timer-in-ms: 30000
client:
service-url:
defaultZone: http://${my-config.eureka.instance.hostname}:8000/eureka/
register-with-eureka: false
client A and B:
eureka:
instance:
lease-renewal-interval-in-seconds: 30
lease-expiration-duration-in-seconds: 90
client:
service-url:
defaultZone: http://${my-config.eureka.instance.hostname}:8000/eureka/
registry-fetch-interval-seconds: 30
Well, after plenty of jmeter test, it seems that something was doing a quick refresh of alive instance ignoring the eureka server. local cache will refresh automatically when B was shut down( even shut down by kill -9 , nothing wrong will happen if there are at least one B stiill alive.)
Sorry it's not entirely clear to me what you're trying to achieve? What's the observed behavior vs the expected behavior in your test setup?