Graceful shutdown means that the service instance can be stopped safely and smoothly without affecting the ongoing business. A Dubbo service may be both a service provider and a service consumer. When the service is stopped:
- Consumers will no longer request stopped service instances
- The request being processed by the service instance can be processed normally
scenes to be used
- Stop the service with
- Stop the service through
/shutdownof SpringBoot Actuator
Dubbo 3.0 and above supports different types of Java applications, including SpringBoot applications, Spring applications, and non-Spring applications.
How to use
Set the graceful shutdown timeout, the default timeout is 10 seconds, if it times out, it will be forced to shut down. This parameter can be configured in the dubbo.properties file, for example: 30 seconds.
# Stop service waiting time, unit: milliseconds dubbo.service.shutdown.wait=30000
Dubbo uses JDK’s ShutdownHook to complete graceful shutdown, so if the user uses
kill -9 PIDand other forced shutdown commands, it will not execute graceful shutdown, and will only execute when
kill PIDis passed.
Verify that Dubbo’s ShutdownHook is executed. You can find the keyword in the log file:
Run shutdown hook now.
If Spring is used, please upgrade to version 4.2 and above, it is recommended to use version 5 or above
If SpringBoot is used, Dubbo’s ShutdownHook will be executed before SpringBoot’s ShutdownHook, If you use SpringBoot 2.3 and above, it is recommended to use it with SpringBoot’s graceful shutdown, and configure it in the configuration file application.yml:
server: shutdown: graceful
- If the ShutdownHook does not take effect, you can call it yourself according to the specific scenario:
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.