Open anarthal opened 10 months ago
My suggestion here is to use share-nothing io_contexts
, the exact number will depend on the number of CPU cores available, so it would be good to make this a command like parameter. To be able to have one listener per io_context
listening on the same port, you have the set SO_REUSEPORT
like this
int one = 1;
auto const ret =
setsockopt( acceptor_.native_handle()
, SOL_SOCKET
, SO_REUSEPORT
, &one, sizeof(one));
if (ret == -1) {
log::write( log::level::err
, "Unable to set socket option SO_REUSEPORT: {0}"
, strerror(errno));
}
We currently run a single-threaded io_context. Consider how we can make it multi-threaded (one context per thread vs. multiple threads and one context).