3 ms·
It won't help much for several reasons: Context switches are expensive. Very expensive. So your system runs overhead in the operating system. And you need to s
by jlouis 14y ago
It won't help much for several reasons:
Context switches are expensive. Very expensive. So your system runs overhead in the operating system. And you need to spawn a process per request.
Pooling processes is a problem as well. If we only have 4 workers in the pool, then we have to queue requests on one of the 4 workers. But we don't know how expensive those requests are to serve, a priori. Even knowing the queue length or the queue sojourn time won't be able to divulge this information to us, only help a little. More workers just push the problem out further.
If you want to be fast, you need:
The ability to switch between work quickly, in the same process.
The ability to interleave expensive work with cheap work.
The two main solutions are evented servers: Node.js, Twisted, Tornado (both python); and preemptive runtimes: Go, Haskell, Erlang (of which Erlang is the only truly preemptive). I much prefer the preempted solution because it is automatic and you don't have to code anything yourself.
There is a strong similarity to cooperative and preemptive multitasking in operating systems by the way. Events are cooperative. Do note there are no more cooperative operating systems around which you use on a daily basis :)