3 ms·
Not exactly. While there are ways to conflate a connection with a thread, these are not always fixed pairs. Generally, it depends on the kind of connection acti
by strmpnk 13y ago
Not exactly. While there are ways to conflate a connection with a thread, these are not always fixed pairs. Generally, it depends on the kind of connection activity and a bit on which operating system. Event based IO is simply pushing information that kernel schedulers already use into user space. The trade-offs really depend on where you need control the most.
Many kernels can do a pretty good job at general purpose networking but at this scale you tend to care about the details and so more of these systems tend to push the decision making to the program using APIs like epoll & kqueue (Linux and *BSD respectively). Keeping this information transfer cheap for millions of sockets is not as trivial as just using the API but it's a necessary step to control overhead.
Whether your user space code uses threads in places to get work done is often misunderstood as well since thread doesn't always mean a single logical thread in a program. Erlang, in SMP mode, uses threads to run it's own process schedulers (much like an operating system). The operation of these schedulers is handled in such a way that IO can efficiently block a process and the scheduler can move onto other things in queue. So, in many ways, it's the same ideas we had on the bare OS but with more specific implementation governed by Erlang's philosophy.