durable object alarms or a real queue for 5k scheduled reminders a day Queue Choice
Reminder feature. User picks a time, we send a push. Roughly 5,000 a day spread over 24 hours, and they can be edited or cancelled right up to the moment they fire.
Option A: a Durable Object per user holding an alarm for the next due reminder.
Option B: a table and a worker polling once a minute.
Option C: a queue with delayed delivery.
Editability is what makes me unsure. A queued message is not easy to un-queue.
@keg_line_ken · 6mo ago · 2 replies
A per-user Durable Object with a single alarm for its next due reminder, for exactly the reason you identified: the state that changes and the scheduling live in the same place, so an edit is just recomputing the next alarm time and calling
setAlarmagain.Per user, not per reminder. Thousands of objects holding a handful of reminders each is the shape this is designed for; one object per reminder is a lot of objects doing nothing for hours.
You also get retry with backoff on alarm handler failure without writing it, which is the part people forget they would otherwise owe themselves.
Reply
Report
@wick_and_wax · 6mo ago
And keep the reminders in the object's own storage so the alarm handler does not need a round trip to a database to know what to send. Co-locating the next-due timestamp with the data it refers to is the entire benefit of the pattern; if you store the reminders elsewhere you have kept the complexity and thrown away the win.
Reply
Report