Skip to content
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

Configure quiet period for shutting down Netty resources #24538

Closed
bclozel opened this issue Feb 17, 2020 · 3 comments
Closed

Configure quiet period for shutting down Netty resources #24538

bclozel opened this issue Feb 17, 2020 · 3 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@bclozel
Copy link
Member

bclozel commented Feb 17, 2020

As of reactor/reactor-netty#860, Reactor Netty allows to configure the quiet period when disposing of the Netty resources.

We should expose this as an option in ReactorResourceFactory, as the default quiet period of 2 seconds can be a problem in test suites or while developing an application (e.g. Spring Boot devtools).

@bclozel bclozel added in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement labels Feb 17, 2020
@bclozel bclozel added this to the 5.2.4 milestone Feb 17, 2020
@bclozel bclozel self-assigned this Feb 17, 2020
@bclozel
Copy link
Member Author

bclozel commented Feb 17, 2020

Before we implement this, I'd like to run things by @violetagg to make sure we're on the right track.

Since reactor/reactor-netty#860, there are additional methods on LoopResources to specify the quiet period when shutting them down. In Spring Framework, we have a ReactorResourceFactory that allows developers to configure in a central place LoopResources and ConnectionProvider.

In Spring Boot, we're creating a ReactorResourceFactory bean that's injected in WebClient instances and the Reactor Netty server. Global resources are used by default. The ReactorResourceFactory class implements the DisposableBean interface, so that the application context cleans up resources when the context is shutting down.

I've got a couple of questions regarding this new configuration option:

  1. In your opinion, is configuring the quiet period + timeout options on ReactorResourceFactory the right way to go? Those options are not available on Reactor Netty DisposableServer, so I guess this is the right place?

  2. Is there a preferred order when shutting things down between the Reactor Netty DisposableServer and LoopResources? What happens if the resources are shut before the server or vice versa?

  3. If we shut the DisposableServer down first and then the LoopResources, will the server try to clean up those resources first? In that case, we might still get the 2s quiet period by default?

@sbrannen
Copy link
Member

Temporary workaround for WebClientDataBufferAllocatingTests, where appropriate values for the durations are debatable:

@AfterAll
void destroyReactorResourceFactory() {
	if (factory.isUseGlobalResources()) {
		HttpResources.disposeLoopsAndConnectionsLater(Duration.ofMillis(50), Duration.ofMillis(50)).block();
	} else {
		this.factory.destroy();
	}
}

@violetagg
Copy link
Member

  1. In your opinion, is configuring the quiet period + timeout options on ReactorResourceFactory the right way to go? Those options are not available on Reactor Netty DisposableServer, so I guess this is the right place?

You can run the server with

  • global resources -> so you do not want to shut them down when the server shuts down
  • when the user provides the LoopResources, the user knows whether he/she wants to shut them.

So DisposableServer does not shut down the resources

  1. Is there a preferred order when shutting things down between the Reactor Netty DisposableServer and LoopResources? What happens if the resources are shut before the server or vice versa?

First stop the LoopResources then the DisposableServer so that you wait for the running tasks while the server is still alive.

  1. If we shut the DisposableServer down first and then the LoopResources, will the server try to clean up those resources first? In that case, we might still get the 2s quiet period by default?

DisposableServer does nothing with LoopResources, the opposite - when you shut down the LoopResources they will close the opened connections.
The only thing that DisposableServer does is when you use global resources. Then when DisposableServer shuts down the connection pool cache is cleaned for the connections that contain DisposableServer address as a remote address.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants