|
|
|
|
|
by jrockway
5997 days ago
|
|
The thing is, I need those database results -- I can't do anything else until I have them. You could start requesting the database results for a user that is now waiting in the tcp connect queue, cutting latency significantly. Most people handle this with load balancing between processes, but your blocked-for-DB-results-process is sitting idle using system resources, like memory. If you only have one user using your site at a time, then this isn't a concern. But for everyone else, blocked processes are wasteful. but require too much fiddling when doing traditional stateless web work Well, yeah, because you don't have threads. When you do, everything is handled by libraries for you; you can think you're blocking, but actually not block the process. |
|
That's already how it works. If one process is blocked waiting for results, another process will get it's turn. Apache is one process per HTTP connection (when not running threaded).
> but your blocked-for-DB-results-process is sitting idle using system resources, like memory.
Either way it will need to use system resources. I can't throw away the resources of the user waiting for results, I need that once the results come in! Processes really don't take up that much memory and typically you're reusing a small number of them over and over anyway.
> If you only have one user using your site at a time, then this isn't a concern.
If somebody is blocked then someone else's request gets a turn at the CPU. Blocking a single process is completely inconsequential to multi-process web server serving multiple users.