You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Default pool size for the Redis RedisMessageListenerContainer.taskExecutor #485
The RedisMessageListenerContainer uses a SimpleAsyncTaskExecutor to dispatch the messages. This causes problems regarding thread creation and repletion, see issue #483.
It makes sense to make spring-session inject a Pooled TaskExecutor into spring-data-redis. We use a pool size of 10.
From a quick check, it seems like #314 / #374 added a way to plug in custom Redis listener executors, but the default still falls back to SimpleAsyncTaskExecutor when no custom beans are defined.
Is this still something you’d like to change? If so, is there anything I should keep in mind before I start on a PR?
Following up on my earlier question, I looked a bit deeper into the execution model here.
It seems like treating this only as a “default pool size” change may be a bit too narrow. If Spring Session only sets a default RedisMessageListenerContainer#setTaskExecutor, Spring Data Redis will use that same executor as the subscriptionExecutor when no separate subscription executor is configured. Since subscription work is long-running while message dispatch is bursty, that could accidentally couple two different execution concerns.
provide a safer default for message dispatch so the default path does not create an unbounded number of platform threads
avoid accidentally using that dispatch executor for Redis subscription work
make lifecycle/shutdown ownership explicit for any executor Spring Session creates
Before I work on a PR, does this framing match the intent of this issue? Or would you prefer this to stay scoped to a simpler taskExecutor default / pool-size change?
If this direction sounds reasonable, I can prepare a small draft PR with tests covering the default case and the existing task/subscription executor override cases.
Hi @rwinch, I'd like to work on this, building on @lsh1215's analysis above. My plan:
When no springSessionRedisTaskExecutor is defined, use a small bounded ThreadPoolTaskExecutor for message dispatch instead of falling back to SimpleAsyncTaskExecutor.
When no springSessionRedisSubscriptionExecutor is defined, set a separate subscription executor, so the long-running subscription doesn't hold a dispatch-pool thread.
Keep user-defined executors exactly as they are today, and make sure executors created by Spring Session shut down with the context.
Add tests for the default and override cases, and update the "Redis TaskExecutor" docs section.
Would you accept a change to the default, or would you rather keep SimpleAsyncTaskExecutor and only improve the docs? Happy to go either way.
@vipul080 Glad to see someone else looking into this! When I commented earlier, I got the sense that this isn't a top priority for the maintainers since it's a fairly old and small issue. Putting up a draft PR with tests is probably the best way to move it forward.
Activity
rwinch commentedon Apr 15, 2016
@rolandgroen Thanks!
cc I believe you were interested in this too @tsachev
tsachev commentedon Apr 16, 2016
@rwinch Yes I opened #314 some time ago and after a discussion we agreed to leave
SimpleAsyncTaskExecutoras default and provide an extension point for the executors. This was implemented in PR #374.I agree that
SimpleAsyncTaskExecutoris terrible default in case ofspring-session.In my project I think we use something like the one configured in this test
https://github.com/spring-projects/spring-session/blob/master/spring-session/src/integration-test/java/org/springframework/session/data/redis/taskexecutor/RedisListenerContainerTaskExecutorITests.java#L100
I.e. single thread executor for events and the
SimpleAsyncTaskExecutorfor the subscription.kunalvarpe commentedon Mar 6, 2023
I would like contribute, Can someone mentor/help me here?
lsh1215 commentedon Jun 24, 2026
Hi, I’m thinking of taking a look at this one.
From a quick check, it seems like #314 / #374 added a way to plug in custom Redis listener executors, but the default still falls back to
SimpleAsyncTaskExecutorwhen no custom beans are defined.Is this still something you’d like to change? If so, is there anything I should keep in mind before I start on a PR?
lsh1215 commentedon Jun 27, 2026
Following up on my earlier question, I looked a bit deeper into the execution model here.
It seems like treating this only as a “default pool size” change may be a bit too narrow. If Spring Session only sets a default
RedisMessageListenerContainer#setTaskExecutor, Spring Data Redis will use that same executor as thesubscriptionExecutorwhen no separate subscription executor is configured. Since subscription work is long-running while message dispatch is bursty, that could accidentally couple two different execution concerns.So the safer direction seems to be:
springSessionRedisTaskExecutorspringSessionRedisSubscriptionExecutorBefore I work on a PR, does this framing match the intent of this issue? Or would you prefer this to stay scoped to a simpler
taskExecutordefault / pool-size change?If this direction sounds reasonable, I can prepare a small draft PR with tests covering the default case and the existing task/subscription executor override cases.
vipul080 commentedon Nov 17, 2026
Hi @rwinch, I'd like to work on this, building on @lsh1215's analysis above. My plan:
springSessionRedisTaskExecutoris defined, use a small boundedThreadPoolTaskExecutorfor message dispatch instead of falling back toSimpleAsyncTaskExecutor.springSessionRedisSubscriptionExecutoris defined, set a separate subscription executor, so the long-running subscription doesn't hold a dispatch-pool thread.Would you accept a change to the default, or would you rather keep
SimpleAsyncTaskExecutorand only improve the docs? Happy to go either way.lsh1215 commentedon Nov 19, 2026
@vipul080 Glad to see someone else looking into this! When I commented earlier, I got the sense that this isn't a top priority for the maintainers since it's a fairly old and small issue. Putting up a draft PR with tests is probably the best way to move it forward.