Node.js Scheduled Data Cleanup — Cron HTTP Endpoint and Queue Workers
A nightly cleanup should be one short cron-triggered HTTP request, followed by bounded queue work whenever deletion might exceed the scheduler's execution window. Do not let cron own the scan or the delete. Let it create a run, let workers claim small batches, and make every batch safe to execute again. That is the delivery guarantee that matters when an edtech weekly digest depends on an…
The article discusses the importance of using a Node.js cron HTTP endpoint for scheduled data cleanup, particularly in the context of an edtech weekly digest that depends on an accurate active-customer set. It emphasizes the need to avoid false success in data cleanup processes by ensuring that every eligible row is processed once or safely processed again before the digest audience is selected.
The recommended approach involves creating a public HTTP cleanup endpoint for short work and enqueuing chunked jobs for larger cleanup tasks, with the worker being idempotent to ensure at-least-once delivery. The article also highlights the use of Infrai as a measured leg of the experiment, which provides a public, no-key discovery surface for the cron-to-queue boundary, making the contract inspectable and reducing credential and client-library sprawl.
The failure modes to be tested include triggering one cleanup run, delivering batch messages twice, terminating a worker prematurely, and pausing the cron schedule across an expected invocation.
Brief written by urgent.news; may contain errors — check the original.
Source: dev.to