Scanning wastes work
Repeatedly checking every reminder means doing lots of work, even when nothing is due.
When every reminder has its own deadline, how do you know what to send next? Explore two ways to keep time at scale.
See it in actionWatch reminders find their moment
Each strategy keeps its own progress. New reminders are added to both. Reset both restores the original set. Switching strategies pauses playback.
This is a simulated 60-second example. It assumes ideal processing and sends no real notifications.
A handful of reminders is easy. Millions of reminders require a more thoughtful way to find what’s due.
Repeatedly checking every reminder means doing lots of work, even when nothing is due.
Giving every reminder a separate waiting thread consumes memory and other resources.
The scheduler needs an efficient way to find the next deadline, then do the work when it arrives.
The right choice depends on how precise your reminders need to be—and how much scheduling work you can afford.
Think of a priority queue: the earliest deadline is always at the top, ready to be picked up.
Think of a clock with buckets: reminders are grouped into slots and processed together.
Here, n is the number of queued reminders and k is the number in a slot. These are data-structure costs; sending notifications and displaying statistics require additional work. The playground shows one 60-second cycle, rather than a continuously rotating production wheel. A hierarchical timing wheel uses multiple levels to handle near and distant deadlines. Real systems also need persistence, retries, and a plan for coordinating workers.
Don’t check everything.
Make time work for you.