4 ms·
The author does mention that you should probably stop at using Threads and passing data around via channels... but then mentions the C10K problem and says that
by brabel 3y ago
The author does mention that you should probably stop at using Threads and passing data around via channels... but then mentions the C10K problem and says that sometimes you need more... but does not answer the question that I think is begging to be asked: does using Rust async with all the complications (Arc, cloning, Mutex whatever) does actually outperform Threads/channels?? Even if it does, by how much? It would be really interesting to know the answer. I have a feeling that Threads/channels may be more performant in practice, despite the imagined overhead.
- Pauan 3y agoThreads cannot scale at all, because you're limited to the number of threads (which is usually quite small). Async code can scale essentially infinitely, because it can multiplex thousands of Futures onto a single thread. And you can have millions of Futures multiplexed onto a dozen threads. This makes async ideal for situations where your program needs to handle a lot of simultaneous I/O operations... such as a web server: http://aturon.github.io/blog/2016/08/11/futures/ http://aturon.github.io/blog/2016/08/11/futures/ Async wasn't invented for the fun of it, it was invented to solve practical real world problems.
- vacuity 3y agoThreads, at least on Linux, are much more lightweight than you seem to think. Async Rust can scale better, of course, but you're overexaggerating your case.
- mrfox321 3y agoIf your system cannot be decomposed away from shared mutable state, then you cannot avoid lifetime management and synchronization primitives. Ultimately, it depends on your data model.
- westurner 3y agoThere's not a good distributed concurrent benchmark in the Techempower Web Framework benchmarks, because the Multiple Queries and Fortunes test programs don't use any parallelism or concurrency primitives to win at fast SQL queries. https://www.techempower.com/benchmarks/#section=data-r21&test=query https://www.techempower.com/benchmarks/#section=data-r21&tes... From https://news.ycombinator.com/item?id=37289579 https://news.ycombinator.com/item?id=37289579 : > I haven't checked, but by the end of the day, I doubt eBPF is much slower than select() on a pipe()? Channels have a per-platform implementation. - "Patterns of Distributed Systems (2022)" (2023) https://news.ycombinator.com/item?id=36504073 https://news.ycombinator.com/item?id=36504073