Current state of the world.
- I have a fixed size Queue of items.
- Consumers get items from the Queue at different rates. It changes overtime, I.e 10 request by minute , tomorrow it can be 20 request by minute and so on. It changes overtime.
- Items are put on the Queue to keep up with the desired size of the Queue.
- The rate of putting items into the queue is also not constant overtime. It can vary.
Problem:
- find the a size of a queue that ensures that queue are not empty.
With a fixed size queue, we would need to keep a huge size of queue so that the changes to dry out the queue are reduced
So a better approach would be to dynamically change the size of the queue, so that based on the rate of consumers and the rate of producers we find an optimal size of a queue such as:
- We avoid running out it items on the Queue
- We avoid keeping a waste of items by keeping lot of items on the queue.
- Maybe the ideal size is keeping the Queue 25% from getting empty.
question from:
https://stackoverflow.com/questions/65861486/find-an-algorithm-to-dynamically-optimize-the-size-of-the-queue 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…