-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add configuration to control shutdown behavior of event loop groups #3582
Comments
@wololock This would be a matter of adding support for configuration like the following in NettyHttpServerConfiguration
The client also can create an event loop so the configuration should probably be added there as well - HttpClientConfiguration In addition we have configuration for event loops with DefaultEventLoopGroupConfiguration |
Thanks, @jameskleeh! Your suggestion is very helpful. I'm going to investigate this solution. Feel free to assign this ticket to me for better visibility. I will get back to you soon. |
@jameskleeh I have discovered one thing and I would like to ask for your opinion. I put a breakpoint at
The problem is that this default shutdown quiet period is not configurable at the classes implementing I guess there are many ways to solve it, but here are two things that came to my mind. 1. Add
|
There is one more thing users creating CLI apps with Micronaut and the declarative HTTP client can do - adding |
Task List
Description
I experienced one side effect of using a commonly shared event loop group for handling incoming requests and sending requests using the declarative HTTP client in the command-line application scenario. The default
shutdownGracefully
method implementation uses 2 seconds shutdown quiet period. It does not affect much long-running microservice like applications. However, it adds an unnecessary 2 seconds lag to the short-living apps like the command-line app or the serverless function. I created a demo app that calls https://api.chucknorris.io/jokes/random endpoint using Micronaut's declarative HTTP client as well as a regular Java 11 HTTP client. While the second one responds in ~300ms, the first one keeps the process running for 2 seconds after the output gets printed to the console.I checked if there is a simple way to override this behavior in the current state of the framework, but I couldn't find a single easy to apply solution. I tried to configure a separate
eventLoopGroup
for thehttp.client
and then inject extendedEventLoopGroup
that overrides the default behavior of theshutdownGracefully
method. I was thinking about injecting the defaulteventLoopGrooup
and decorating it with the custom implementation of that interface, but when I've seen tons of methods that had to be decorated, I said "ok, enough."I would like to volunteer and create a PR with a working solution, but I would like to ask what do you think about it in the first place. Micronaut's
@Bean(preDestroy)
allows us to define a method via string and it expects that the destroy method does not take any parameters. I see two potential options:@Bean(preDestroy)
to support a parameterized method, so one can pre-configure the bean to use zero seconds quite period when necessary,EventLoopGroup
with configurable options passed toshutdownGracefully
method.The declarative HTTP client is powerful, and I think people love it so much that they would like to use it in the command-line apps or serverless functions. However, when every cli/function execution adds 2 seconds to something that takes less than a second, it feels like something could be improved in this area.
Steps to Reproduce
Expected Behaviour
There should be a way to configure an event loop group to shut down instantly.
Actual Behaviour
There is no simple way to override the default
shutdownGracefully
method to shut down an even loop group instantly.Environment Information
Example Application
The text was updated successfully, but these errors were encountered: