Urgent.News

What's breaking now, across thousands of outlets.

Tech

Node.js Report Scheduling: Combining Cron Jobs with Worker-Based Long-Running Tasks

A cron process should create one durable scheduling record and exit. A worker queue should own report generation, subscriber fan-out, retries, and delivery state. That boundary keeps a slow daily shipment report from turning a timer into an accidental job runner, while still leaving room to choose latency or cost deliberately. Short answer: run the scheduler at a fixed time, claim the day with an…

The article discusses the best approach to combining a cron job with a worker-based queue for scheduling long-running tasks, using the example of a fintech operation that sends daily shipment-status reports to subscribers. The key points are:

1. The cron job should only create a durable scheduling record and exit, while the worker queue should handle report generation, subscriber fan-out, retries, and delivery state. This separation prevents a slow report from turning the timer into an accidental job runner.

2. The scheduler should run at a fixed time, claim the day with an idempotency key, enqueue one report job, and have a small timeout. The worker needs a lease, bounded concurrency, durable progress, and a clear rule for permanent failure.

3. The article outlines several invariants to keep in mind when combining a cron job with a worker-based queue. These include keeping it simple, ensuring only one active report run per tenant and report date, allowing workers to execute jobs more than once without causing unbounded copies to subscribers, retaining reports long enough for delivery retries, and defining failure categories.

The conclusion is that the cron job should stop before the report is finished, as its primary responsibility is to determine the intended run, record it, and publish a message. This approach allows for better fault tolerance, scalability, and control over the reporting process.

Brief written by urgent.news from Dev.to's own syndicated text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Choose an Image Generation Model DALL-E 3 SDXL and Flux for Web App Speed

TL;DR: choose the smallest image-generation system that meets the visual bar for the marketplace workflow, then measure time to a usable result instead of chasing a model leaderboard.

  • Evaluate models with 30-50 prompts covering various asset classes.
  • Record request acceptance and asset usability timestamps.
  • Consider service boundary, deployment control, and observed latency.

Meal finder

A Minimalist Recipe Finder Powered by TheMealDB API Sometimes, deciding what to cook is harder than actually cooking. There are so many recipes online, but finding something that matches what you're…

  • Meal Finder simplifies recipe search using TheMealDB API
  • Users input keywords to view instant recipe results
  • Project aims to streamline meal discovery online

More from Saturday 24 October →