3 ms·
Spiky workloads, safely persisting data, decoupling components, and enabling asynchronous processing are all things that can be provided by a stack or a heap as
by fwlr 4y ago
Spiky workloads, safely persisting data, decoupling components, and enabling asynchronous processing are all things that can be provided by a stack or a heap as well. The call stack in any given programming language is a good example of a stack for handling spiky workloads, for instance. A min-heap is more flexible than a queue for handling async/decoupled/pubsub stuff (and arguably more correct for many use cases).
The thing that queues are good for is enforcing order: when I get to the front of the queue and it’s time to do my thing, I have a guarantee that anyone who entered the queue before me has already done their thing, and anyone who entered the queue after me has not yet had a chance to do their thing. This is a useful guarantee for tasks that have an order dependence, for example database operations looking to guarantee consistency.