Skip to content

Implement complete Async request execution flow #259

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

Closed
artem-ag opened this issue Jun 13, 2020 · 1 comment
Closed

Implement complete Async request execution flow #259

artem-ag opened this issue Jun 13, 2020 · 1 comment

Comments

@artem-ag
Copy link
Contributor

Is your feature request related to a problem? Please describe.
AbstractGraphQLHttpServlet implements async request execution by deferring execution to user provided ExecutorService. This still means that a new thread is held per request being executed. Complete async support would allow to avoid holding any threads while service is waiting for any downstream IO to complete increasing GraphQL server scalability.

Describe the solution you'd like
GraphQLInvoker already supports async execution by returning CompletableFuture.
To solve this several classes need to be converted to run execution asynchronously and call Jetty asyncContext.complete() after last of CompletableFuture is complete.
These include:

  1. GraphQLInvoker.query() to become async and return CompletableFuture.
  2. HttpRequestHandlerImpl invoke() and execute() methods to become async and return CompletableFuture. handle() method either to become async, or accept Jetty AsyncContext to call asyncContext.complete() upon execute() completion.
  3. AbstractGraphQLHttpServlet.doRequest() will need to change the way callback are processed after other methods will be converted to Async.

Describe alternatives you've considered
Alternative is to not use Async execution at all, to reduce overhead of transferring "work" from Jetty thread pool to asyncExecutor thread pool and increasing Jetty thread pool size instead. Number of parallel requests that can be processed is limited by the size of Jetty thread pool. In async mode number of parallel requests is limited by the size of GraphQLConfiguration.asyncExecutor. That's practically the same as limiting at Jetty level, except additional "work" is required to move request execution from Jetty thread pool to GraphQLConfiguration one.

Additional context
N/A

@olim7t
Copy link
Contributor

olim7t commented Sep 17, 2020

+1, I'm in a situation where I'm fetching data from an async backend, so that would be really useful.

In async mode number of parallel requests is limited by the size of GraphQLConfiguration.asyncExecutor. That's practically the same as limiting at Jetty level, except additional "work" is required to move request execution from Jetty thread pool to GraphQLConfiguration one.

Completely agree with that.

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

No branches or pull requests

2 participants