Skip to content

Warn about use of SimpleAsyncTaskExecutor for async requests [SPR-16203] #20751

Closed

Description

@spring-projects-issues

Rossen Stoyanchev opened SPR-16203 and commented

The Spring MVC Java config and XML namespace allow configuring an AsyncTaskExecutor originally used for java.util.concurrent.Callable return values and by default a SimpleAsyncTaskExecutor is used with the recommendation to configure a task executor with a thread pool for use under load. 

Now that the same executor is also used for blocking writes when streaming with Flux or Observable, we should warn more proactively about this in the logs. 


Affects: 5.0.1

Issue Links:

Referenced from: commits 4b861ae, 7b3a72f, 7ea8ecb

Activity

  1. spring-projects-issues commented on Nov 15, 2017

    @spring-projects-issues
    CollaboratorAuthor

    Rossen Stoyanchev commented

    In the mean time applications can use WebMvcConfigurer#configureAsyncSupport to customize the thread pool.

  2. spring-projects-issues commented on Jul 11, 2018

    @spring-projects-issues
    CollaboratorAuthor

    Rossen Stoyanchev commented

    Adding 5.0.8 since this is a one-time warning in the logs.

  3. spring-projects-issues commented on Aug 6, 2018

    @spring-projects-issues
    CollaboratorAuthor

    Michal Domagala commented

    Could you clarify whether or not WebMvcConfigurer#configureAsyncSupport is solution or workaround? I can't find any commit nor Jira ticket for more elegant configuration

  4. spring-projects-issues commented on Aug 6, 2018

    @spring-projects-issues
    CollaboratorAuthor

    Rossen Stoyanchev commented

    To make sure we're talking about the same thing, this is only required when streaming to the response (e.g. Server-Sent Events, or application/stream+json) via Flux or io.reactivex.Observable where each event is written to the response via a blocking write to the ServletOutputStream. If you do that, on the first such response, a warnings appears in the logs, and plugging in a thread pool via WebMvcConfigurer#configureAsyncSupport is a solution, not a workaround.

    This is not needed if you return a single value, such as Mono, or a Flux that's then collected to a Mono<List> which is the case for "application/json". In those cases a warning will not appear in the logs. So the warning can be used to check whether this is needed or not.

  5. spring-projects-issues commented on Aug 6, 2018

    @spring-projects-issues
    CollaboratorAuthor

    Michal Domagala commented

    Yes we are talking about streaming case. I would like to say that usually Spring Boot configures automatically required infrastructure, so need to configure ThreadPoolTaskExecutor from scratch is not typical.

    If autoconfiguration is not possible, sample in documentation with default settings and/or good practice would be useful.

  6. spring-projects-issues commented on Aug 6, 2018

    @spring-projects-issues
    CollaboratorAuthor

    Rossen Stoyanchev commented

    I believe something is being added to Boot for this. Stéphane Nicoll?

  7. spring-projects-issues commented on Aug 6, 2018

    @spring-projects-issues
    CollaboratorAuthor

    Stéphane Nicoll commented

    As of today actually and available in the next milestone of Spring Boot 2.1, see #1563 for more details. There will be a TaskExecutorBuilder that you can use to easily build custom ThreadPoolTaskExecutor instances.

    In the meantime, I am afraid you'll have to implement WebMvcConfigurer.

  8. spring-projects-issues commented on Aug 6, 2018

    @spring-projects-issues
    CollaboratorAuthor

    Michal Domagala commented

    Great, big thanks!

  9. added
    type: enhancement
    in: web
    on Jan 11, 2019
  10. added this to the 5.0.8 milestone on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: webtype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions