tomcucinotta / distwalk

Distributed processing emulation tool
GNU General Public License v3.0
2 stars 4 forks source link

Allow for selecting various listen/accept modes #47

Open tomcucinotta opened 2 months ago

tomcucinotta commented 2 months ago

Currently, dw_node spawns multiple connection workers, each of which creates its own listen/accept socket (thread_infos[i].listen_sock), which is bound to the same IP:port exploiting the SO_REUSEPORT capability of the kernel. This way, the balancing of the incoming connections to the worker threads is left to the kernel.

There are at least other 2 accept modes that are worth being supported:

The current implementation might be the most scalable one exhibiting the lowest connect and request latency (saving context switches), however the last option above is probably among the most widely used, as it gives control over the balancing logic, at the cost of two additional context switches to go through the parent thread for each established new connection.

The three options might be selected with something like:

dw_node --accept-mode=child|child-shared|parent

The currently implemented mode, child, would be the only one needing SO_REUSEPORT. The parent mode should have further options to customize the load-balancing logic (e.g., round-robin, least-conn, ...).

tomcucinotta commented 2 months ago

First attempt is in master; issue still open until we have a test-case checking the 3 accept-modes are doing what they're supposed to do.