Cron vs Workflow Orchestrator: Failure Test Results

Cron vs workflow orchestrator test of a nightly ETL job under failures

The cron vs workflow orchestrator question got a hands-on test: one nightly job, scheduled five ways on one machine, then broken the same way each time. The job pulls orders from an API, transforms them, loads them into Postgres and sends a report. The setups were plain cron, hardened cron, a Kubernetes CronJob, Kestra and Prefect.

The failures and the scoreboard

The failures were: a step that dies midway, a run still going when the next starts, a poison record, a duplicated run, a reboot during a run, and downtime while schedules came and went. Afterwards the missed days were backfilled by hand. Out of 34 nightly partitions, before any manual repair:

  • Plain cron ended with 9 bad partitions (absent, partly loaded or loaded twice) and never alerted.
  • Hardened cron left 6 missing. The dead-man switch caught only 2 of the 4 incidents responsible.
  • The Kubernetes CronJob left 4 missing. A pod retried after the reboot loaded the wrong day, while both Jobs involved showed Complete.
  • Kestra left 1 missing, the poison record. A reboot stalled its scheduling, for 6.5 minutes in one run and 11 in another, before it recovered unaided.
  • Prefect left 18 missing, covered below.

The takeaway is that an orchestrator is not automatically safer.

Why Prefect scored worst

Prefect’s retries did not cover a process crash. After a reboot, a run that no longer existed held the deployment’s only concurrency slot, and nothing ran for 42 minutes until the tester forced that run to Crashed. A second reboot did the same. Adding the zombie-run automation from Prefect’s documentation brought a reboot re-test back to normal after 90 seconds.

What each tool does and doesn’t do

Cron runs a command. With no notion of a run, it cannot retry, deliberately skip, catch up after an outage or tell anyone something broke. Everything else is in your script. Adding flock, timeouts, retries and a dead-man ping helps a great deal. Even so, flock -n quietly converts an overlap into a skipped day, and a dead-man check can’t see a killed run if the following run succeeds.

Kubernetes CronJobs retry pods and keep a Job record. The weakness is a pod that derives yesterday from the clock, which loads the wrong day if retried late. After an outage, the CronJob launches just the latest missed schedule.

Kestra recovered each missed schedule using the correct date, and it queued overlapping and duplicate runs. It also has a backfill API. Its soft spot was a reboot during a run. After a graceful shutdown it sat through the full termination grace period before it resubmitted the stuck task.

Idempotent writes decided the data

The orchestrators added a history of each run, per-step retries, and catch-up plus backfill keyed to the scheduled date. Correct data came down to a different question: could the load and the report be repeated without harm? Once repaired, every setup with idempotent writes passed the scorer: right row count each day, no order loaded twice, one report daily. The two without idempotent writes required a delete before each rerun, and they had already sent duplicate reports that no one can pull back.

In the naive mode, rows were appended with commits every 100 rows into a table lacking any unique constraint, as many first attempts do. The hardened version differs from it only in how the load and the report behave. No scheduler fixes a poison record either, so that case needs handling in the job.

What to choose for your jobs

Teams weighing cron vs workflow orchestrator tools should start with the job, not the scheduler. Make every step safe to run twice, pass the scheduled date into the job instead of reading the clock, and alert on missing output rather than on failed processes. If you need run history, per-step retries and backfill by date, an orchestrator earns its keep, but test it against reboots first.

Anyone can rerun the lab on a throwaway Ubuntu 24.04 VM (4 vCPU, 8 GB RAM) running Docker and k3s, with another machine to trigger the failures. Anyone planning a move off cron can run the same breakage against their own setup before trusting it with production data. The next step is to rerun the Prefect reboot case with the zombie-run automation switched on from the start.

Source: devops-daily.com

Written by

Saksham Bhargava

Saksham Bhargava runs Alteroid and has been writing about consumer technology for over five years, covering iPhone, Android, Windows, AI tools and gaming. With an MCA and six years of hands-on web development experience, he tests the features he writes about on his own devices and focuses on clear, practical guides that solve real problems. Away from the screen, he enjoys travelling to places most tourists skip.