Hello Guys.
I am attempting to assemble a Multiple Producer Single Consumer queue using Martin/Nitsan's Single Producer Single Consumer queue.
What I have thus far works but wanted to get your opinions/suggestions to ensure the correctness of my approach.
In a nutshell, I have multiple producers generating events which needs to be dispatched to consumers in strict LIFO order.
I currently use an ArrayBlockingQueue where the producers simply en-queque and a poller thread dequeues and dispatches the events.
With this configuration, I am able to push 10 million events/sec but I in the next phase, I need to push at least 15-17 million/sec (hence the re-design).
Since the number of event producers is fixed, what I am thinking is this:
Different producer threads will enqueue data into separate SPSC queues.
As before, a single poller thread will poll all the queue. If nothing is polled, I apply back pressure by parking the poller thread and then retrying.
If events are polled, I sort them according to their monotonically increasing Id (to maintain FIFO ordering) and finally dispatch them to their respective listeners.
P-Thread1 -> Q1 ==================== | <=
P-Thread2 -> Q2 ==================== | <= Poller Thread | =|=|=|=|=|=|=|=|=|=| Sort | Dispatch
P-Thread3 -> Q3 ==================== | <= (Events polled)
P-Thread4 -> Q4 ==================== | <=
Are their any issues I should be aware of before discarding the trusted ArrayBlockingQueue?
Cheers