Using thread inter-communication to increase my server app's IO throughput; not sure how
- by Howard Guo
My server application creates a new thread for each incoming connection. Incoming requests are serialized in a BlockingQueue. There is one worker thread taking items from the queue, produce a response and send the response through socket.
I have noticed a throughput issue: Currently, worker thread is responsible of sending the response message through socket, thus severely wasting processing power and throughput.
I am considering: rather than sending the response itself, why not telling network IO threads to send the response?
However, when I think about thread inter-communication, I cannot yet figure out how to approach it: Worker thread will produce a response, but how will it inform the response message to IO thread?
Is there a standard/best practice?
Thank you.