(no title)
nullwasamistake | 6 years ago
Say you have 1000 threads. To handle a request each one needs to make 50ms of external or DB calls. In one second, each thread can handle 20 calls. So you can handle 20k requests/second with 1000 threads. But Rust is so fast it can serve 500k requests a second. So with regular threads, you need ~25,000 threads. The OS isn't going to like that.
With async you can run a single thread per core, with no concurrency limits. So you get your 500k requests without overhead. With fibers you just run 20k fibers which is a little bit of overhead but easy to do.
This is the core reason everyone is pushing async and fibers in fast languages. When you can push a ton of requests/second but each one has latency you can't control, regular threads will kneecap performance.
In "slow" languages like Python, Ruby, etc, async/fibers don't really matter because you can't handle enough requests to saturate a huge thread pool anyways.
staticassertion|6 years ago
But yes, eventually, for very heavy cases (more than what I would call "high") you will want async/await.
pjmlp|6 years ago
pcwalton|6 years ago
je42|6 years ago
noncoml|6 years ago
With 8k stack for each, you can easy have 10k-100k threads in a low-end system
MrBuddyCasino|6 years ago
j88439h84|6 years ago