4 ms·
Backend newb, here. I have a dumb question - can someone give me a summary, or blog post to a summary, of the pros /cons of async versus threads? One thing I h
by game_the0ry 5y ago
Backend newb, here. I have a dumb question - can someone give me a summary, or blog post to a summary, of the pros /cons of async versus threads?
One thing I have been using as a way of understanding hi-perf backends is analyzing why the vert.x framework [1] (and its underlying server, netty) does so well on benchmarks [2], but as newb, I do not think I would get a lot form that exercise without a little hand holding.
[1] https://vertx.io/ https://vertx.io/
[2] As of today, #28 on tech empower benchmarks - https://www.techempower.com/benchmarks/ https://www.techempower.com/benchmarks/
- preseinger 5y agoOS Threads: + Simpler programming model - More resource intensive, so you usually need more user code to use them effectively Async + Less resource intensive, so you can have more of them and need less user code for management - More complex programming model Green threads: + Simplest programming model + Resource efficient - Requires a runtime
- duped 5y agoAs with all benchmarks, benchmark your workload. The tech empower stuff is gamed, like all rankings. But first and foremost, concurrency is not parallelism [1]. In my practical experience dealing with both, asycn is a language semantic for concurrency, threads are an OS feature for parallelism. It's a little nonsensical to ask the pros/cons since they are different entirely ; you can use both at the same time (and in practice most async implementations use threads) [1] https://www.youtube.com/watch?v=oV9rvDllKEg https://www.youtube.com/watch?v=oV9rvDllKEg "Concurrency is not Parallelism" talk by Rob Pike.