You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a way to handle each connection by a separate thread?
Background: clients keep the connections alive (connection pool) for long period of the time to send many requests to one connection (one after another). Processing of a request, including reading it and writing it to the socket, is quite heavy (consumes a lot of CPU).
How can I start a new thread for each connection, right after accept() ? The new thread suppose to be created once for entire connection, not for each request.
Thank you in advance.
The text was updated successfully, but these errors were encountered:
I've never thought about this too much but there is no intended mecanism for a procedure to identify the source connection, meaning you can't dispatch the work based on the connection.
That said you have access to a fully async server so you don't need to have one thread per client to maximize CPU occupancy, you can just run the io_context on many threads. You can also have two thread pool, one for the io_context and one to process the CPU intensive part of your processing if you can to make sure the io_context will not starve.
Is there a way to handle each connection by a separate thread?
Background: clients keep the connections alive (connection pool) for long period of the time to send many requests to one connection (one after another). Processing of a request, including reading it and writing it to the socket, is quite heavy (consumes a lot of CPU).
How can I start a new thread for each connection, right after
accept()
? The new thread suppose to be created once for entire connection, not for each request.Thank you in advance.
The text was updated successfully, but these errors were encountered: