Skip to content

Default pool size for the Redis RedisMessageListenerContainer.taskExecutor #485

Open

Description

@rolandgroen

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.

Activity

  1. rwinch commented on Apr 15, 2016

    @rwinch
    Member

    @rolandgroen Thanks!

    cc I believe you were interested in this too @tsachev

  2. added this to the 1.3.0 M1 milestone on Apr 15, 2016
  3. tsachev commented on Apr 16, 2016

    @tsachev
    Contributor

    @rwinch Yes I opened #314 some time ago and after a discussion we agreed to leave SimpleAsyncTaskExecutor as default and provide an extension point for the executors. This was implemented in PR #374.
    I agree that SimpleAsyncTaskExecutor is terrible default in case of spring-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 SimpleAsyncTaskExecutor for the subscription.

  4. added
    status: ideal-for-contribution
    on Sep 12, 2016
  5. removed this from the 1.3.0 M1 milestone on Sep 12, 2016
  6. kunalvarpe commented on Mar 6, 2023

    @kunalvarpe

    I would like contribute, Can someone mentor/help me here?

  7. lsh1215 commented on Jun 24, 2026

    @lsh1215
    Contributor

    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 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?

  8. lsh1215 commented on Jun 27, 2026

    @lsh1215
    Contributor

    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.

    So the safer direction seems to be:

    • keep honoring user-provided springSessionRedisTaskExecutor
    • keep honoring user-provided springSessionRedisSubscriptionExecutor
    • 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.

  9. vipul080 commented on Nov 17, 2026

    @vipul080

    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.

  10. lsh1215 commented on Nov 19, 2026

    @lsh1215
    Contributor

    @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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: redisstatus: ideal-for-contributiontype: enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions