I think that, in most cases, the ArrayBlockingQueue
will perform better than the LinkedBlockingQueue
. However, that is the case when there is alway
My 2 cents:
To start with, the bottom line here is you don't really care about the difference here because even when you are using a plain LinkedBlockingQueue, the performance is good enough when you are delivering some micro-second level systems. So the performance difference here isn't really that great.
If you are writing a mission-critical high performance system and you are using queues to pass messages between threads, you can always estimate the queue size needed by [Queue Size] = [Max acceptable delay] * [Max message rate]. Anything which can grow beyond such capacity means you suffer from a slow consumer problem. In a mission critical application, such delay means your system is malfunctioning. Some manual process might be needed to make sure the system is running properly.
In case your system isn't mission critical, you can simply pause (block) the publisher until some consumers are available.