3 ms·
Also, programming in C, it's very easy use thread-per-connection model especially if synchronization is not necessary. If you want a pool of threads it gets a b
by IgorPartola 17y ago
Also, programming in C, it's very easy use thread-per-connection model especially if synchronization is not necessary. If you want a pool of threads it gets a bit more complex, but if you always spin up a new thread for each connection, it's easy as pie (and in my case doesn't matter since the time spent creating a new thread is negligible compared to the amount of time it'll spend doing useful work).
- vladev 17y agoIf you want to keep the easy thread-per-connection model even with 1M connections you might have a look at Erlang - it takes the best of both worlds (threads and async IO) via its processes (so you get a process-per-connection). I read somewhere that the overhead of a process is just about 300 bytes.
- jrockway 17y agoEvent loops are even easier, and the per-connection overhead is often a single struct. And if you want to do async disk IO, you can do it in another thread. (The IO::AIO module for Perl is a great example of this technique.)