I have a question related to IOCP networking strategy for our C++ server application.
Our server simulates a lot of devices which speak over UDP with short (less than 2K) messages. The server is also bound by a soft real-time constraint of 70-100 milliseconds. Currently the networking part of the application was developed with a thread being started for every socket, which leads to hundreds of threads being started. Their job is to watch for the UDP sockets, and when the data arrives, copy it into the queue of our real-time thread.
We are being asked to support more and more devices and I was thinking that rewriting the communication module using IOCP our server would be more efficient. I developed a prototype based on the code I was able to find online, but the combination of
- WSARecvFrom (Initiates receive)
- GetQueuedCompletionStatus
- OnDataRecieved (A method of my class that gets called when data is copied into my buffer)
does not seem efficient at all. The gaps between data arrival on a given socket are 500-600 milliseconds.
I only started prototyping and did not profile a whole lot. My question are:
Can IOCP be used for my scenario or is it designed for high throughput only? Will WSAAsyncSelect (with hidden windows) be more efficient for my use case?
Thanks in advance, Michael
Edit:
I noticed while profiling that the problem starts with: - WSASendTo - GetQueuedCompletionStatus - OnDataSent
Looks like GetQueuedCompletionStatus doesn't wake up fast enough.