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:
using a single socket, on which all the connection workers listen and accept incoming connections
using a single socket, on which only the parent thread listens and accepts incoming connections, handing over the obtained connection file descriptor to a connection worker thread.
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, ...).
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:
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, ...).