3 ms·
Depending on your platform, how many children you've forked, and your rate of incoming connections, this design could expose you to a thundering herd. You migh
by cperciva 14y ago
Depending on your platform, how many children you've forked, and your rate of incoming connections, this design could expose you to a thundering herd.
You might find that you get better performance by having the parent call accept() and hand off sockets to the children. With sufficient abuse of LD_PRELOAD you can probably do this without making any changes to the child processes -- you just need to override accept() with a function which checks if any sockets have been handed off.
- gdb 14y agoThat's a fair point. Even if your accept() implementation is fine, event-driven workers would instead be select()ing on the shared socket, which can also lead to a thundering herd. I think you'd need quite a few worker threads before this became an issue in practice though.
- cperciva 14y agoIndeed, it's an edge case... but it's a painful one if people do run into it.