Multiple threads processing a ConcurrentQueue
Posted on 2010-08-17
Bit of background, we have a sockets server currently supporting around 500 concurrent users, these users are running lots of different actions all at the same time, thus the sockets server is under a lot of stress.
What we're looking at doing is placing each message that is received from the clients into a managed ConcurrentQueue (.NET 4.0). We've successfully put these into the queue and we can dequeue them on a seperate thread, this works up to a point.
What we'd ideally like is for these messages to be processed asynconously by multiple threads at the same time, but we don't want to have these threads waiting in a while loop because the CPU goes through the roof. Ideally we'd like the queue to be observable and for a thread to kick in and process.
To give some perspective, we probably get 10 requests per second so we can't afford for the queue to be blocking.
What direction should we be heading in with this.