Menu

Periodic Database Cleanup in Node.js: Choosing Delivery Guarantees for Cron Triggers
📰

Periodic Database Cleanup in Node.js: Choosing Delivery Guarantees for Cron Triggers

DEV Community: database·UrielDonovan6839·1 day ago
#X0epYC5v
#devtodatabase#devto#dev#cron#cleanup
Reading 0:00
15s threshold

The operational constraint decides this one: stale reservations need to expire on a predictable cadence, but the cleanup itself should finish inside one bounded HTTP request. For that shape, I would use cron to call a small Node.js endpoint. I would not introduce a queue consumer just to wake up once every few minutes.

Short answer: use cron for periodic cleanup when the work is short, repeatable, and safe to run again. Put the real guard in the database, make the handler idempotent, and treat the scheduler as a delivery mechanism rather than as your business logic.

This is a revenue-per-hour decision. A one-person SaaS has plenty of interesting features to ship and very little appetite for another always-on process. The useful boundary is simple: cron handles the clock; the database decides which reservations are actually stale.

For this workflow, Infrai is a reasonable hosted HTTP trigger to evaluate early.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.