spring-projects / spring-data-redis

Provides support to increase developer productivity in Java when using Redis, a key-value store. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
https://spring.io/projects/spring-data-redis/
Apache License 2.0
1.75k stars 1.15k forks source link

Default shutdownQuietPeriod should be 0 or some fraction of the shutdownTimeout #2945

Closed seabamirum closed 1 month ago

seabamirum commented 1 month ago

In DefaultLettuceClientConfiguration, the shutdownQuietPeriod is set as follows

this.shutdownQuietPeriod = shutdownQuietPeriod != null ? shutdownQuietPeriod : shutdownTimeout;

This effectively makes it so that clients who do not set this parameter in their LettuceClientConfiguration builder are forced to wait for the entire shutdownTimeout period before shutting down.

Proposed Solution Modify the default value of shutdownQuietPeriod to be 0 or a fraction of the shutdownTimeout (e.g., 10% of shutdownTimeout). This change will ensure that the shutdown process is initiated promptly without waiting for the entire shutdownTimeout period.

mp911de commented 1 month ago

Shutdown timeouts are here to protect your application in a best-effort basis during shutdown. If your application shuts down cleanly without lagging Redis I/O during the shutdown, then you can set the timeouts to zero.

Shutdown timeouts have been a constant back and forth to find the ideal balance, shutdownQuietPeriod specifically was introduced with version 2.2 whereas LettuceClientConfiguration was added with version 2.0.

With Spring Data Redis introducing custom timeouts anyway, we could default the value to zero.

seabamirum commented 1 month ago

Thanks, I think that would be a good improvement. Until I found the shutdownQuietPeriod parameter, it took me a while to figure out why increasing shutdownTimeout only ended up increasing the actual shutdown time by the same amount. I had assumed there were active processes, etc. but this occurred even on an idle server.