Best way to handle blocking service methods?
- Dominant language
- Rust
- Stars
- 3.7k
- Forks
- 230
- PR merge metrics
- No merged PRs in 30d
Description
Some of my service's method need to access the db, which means they would block the current thread. Does that mean I should use the `SyncService` instead of `FutureService`?
But then how can I scale to hundreds of simultaneous rpc calls without spawning equally many threads?
Or should I use `FutureService`, but then how could I process any other rpc calls in parallel with a blocking call (e.g. while one call waits on the db)?
What's the best way to handle this?
Is there a way to combine both approaches like in actix where some actors (here rpc methods) are sync and some are async, and both can be part of the same service, because the sync actors (methods) are executed on a threadpool?
If I manually spawn multiple `FutureService`s in different threads, a blocking call in one thread would still block the other calls happening in the same thread at that time.. And they couldn't all listen on the same port, right? So what's the best way to do this? :)
Contributor guide
Assessment
This issue has not been assessed yet.