4 ms·
Why doesn't Elixir/Erlang have this problem too? It's using green threads as well, with 1 "process" per connection, right? Is it not the same kind of schedulin
by robbles 11y ago
Why doesn't Elixir/Erlang have this problem too?
It's using green threads as well, with 1 "process" per connection, right? Is it not the same kind of scheduling?
- codesushi42 11y agoI'm guessing some kind of multiplexing of the sockets is being used in the Erlang case. There's no green thread per every connection. I don't understand what the grandparent is saying though. Yeah, if you create a thread for every request, then you're going to be killed by the memory overhead. This isn't unique to Go, and I remember it being a problem when many noob Java programmers would spawn a thread per request before the introduction of java.nio. The downside with Twisted, Tornado, or whatever in Python is your code isn't parallelized. It's concurrent, yes, but you aren't taking advantage of your multiple cores without forking another Python process due to GIL. Go, Scala, Java etc. are truly multi-threaded and compile to native code from commandline or via JIT. Saying your performance advantage is due to switching from Go to Python is a spurious claim. You weren't doing it right.
- strmpnk 11y agoFor most scaled up examples in Erlang and Elixir, there is a BEAM process (green thread) per connection as well as others (usually arranged as a supervised pool so one can avoid an acceptor bottleneck). There are a few reasons it does better but the biggest is a carefully tuned SMP scheduling mechanism and aggressive preemption policies. Some of these choices actually hurt throughput in favor of fairness and latency. All in the name of reliability over speed.
- codesushi42 11y agoThat's helpful. Thanks.
- gpderetta 11y agoI believe erlang can only block at the top level. This means it doesn't need to keep a stack per thread around but only enough space for a single activation frame.