Rocket: Documentation about threading

Created on 20 Jul 2019  路  2Comments  路  Source: SergioBenitez/Rocket

The rocket.rs guide is not very clear about how rocket manages threading. There is a Rocket.toml attribute about worker threads, but how exactly is it performed? How about async operations in handler executions -- should I call a blocking tokio::run, or are there other concerns as to preventing blocking worker threads? More clarification would be useful for those new to Rust. In particular, if someone came from the nodejs world (likely for webdev), they would tend to have everything async, but is that necessary in Rocket for scalability?

docs request

Most helpful comment

Rocket 0.4 uses hyper 0.10 and runs a given number of workers. Any given request will block on every fairing, guard, route, and catcher that is run for that request, and additionally use synchronous I/O to send the body to the client.

We have been working on upgrading to hyper 0.12 (see also #1008), introducing async routes and I/O. We can ensure the guide explains this better then, along with instructions (perhaps in the CHANGELOG) on how to migrate guards, routes, and responders that are affected.

All 2 comments

Rocket 0.4 uses hyper 0.10 and runs a given number of workers. Any given request will block on every fairing, guard, route, and catcher that is run for that request, and additionally use synchronous I/O to send the body to the client.

We have been working on upgrading to hyper 0.12 (see also #1008), introducing async routes and I/O. We can ensure the guide explains this better then, along with instructions (perhaps in the CHANGELOG) on how to migrate guards, routes, and responders that are affected.

This has been expanded upon in the guide as part of the async changes coming in 0.5: https://github.com/SergioBenitez/Rocket/blob/0909ba2ef60d0d512481796598a8aba04e7cd55c/site/guide/3-overview.md#futures-and-async.

The CHANGELOG / migration guide has not been part of the guide in the past and will be worked on separately, so I'm going to close this for now. Feel free to reopen this or a new issue if there's something more that should be added!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marceloboeira picture marceloboeira  路  3Comments

sphinxc0re picture sphinxc0re  路  3Comments

kitsuneninetails picture kitsuneninetails  路  4Comments

shssoichiro picture shssoichiro  路  4Comments

lambda-fairy picture lambda-fairy  路  4Comments