Getting Started

Best Practices & Performance


Everything on this page assumes the patterns from this section — email campaigns, scheduled jobs, retry with backoff, and content processing. Each practice below links back to the pattern that demonstrates it.

Design Principles

Use Durable Timers Instead of External Cron

A ctx.sleep() in a loop is more reliable than an external cron scheduler because the timer state is journaled alongside the workflow. If your cron daemon and your worker both go down, the external approach loses the schedule. With Orcher, the workflow resumes its sleep countdown automatically on restart — see scheduled jobs for when to use a timer loop versus the Schedule API instead.

Keep Tasks Small and Focused

A task that sends 10,000 emails is hard to retry — if it fails at email 9,999, you either retry all 10,000 or build your own checkpointing. Instead, batch into groups of 100 and let Orcher checkpoint each batch. The checkpoint boundary is the task boundary, so the size of a task is the size of your worst-case replay — the exact tradeoff worked through in email campaigns.

Handle Errors at the Right Level First

The platform already retries a failing task before the error reaches your workflow — so don't hand-roll retries for transient faults. Reserve workflow-level try/catch for policy: counting partial failures, alerting, falling back. Retry with backoff draws the line between the two.

Use Parallel Execution for Independent Steps

If two tasks don't depend on each other — transcoding to MP4 and WebM, uploading three assets — run them concurrently with try_join! (Rust), Promise.all (TypeScript), or asyncio.gather (Python). Each parallel task is still individually journaled and recoverable. The content-processing pipeline shows the DAG shape; the fan-out is free structure.

Record Metrics as a Final Task

At the end of a batch workflow, write a summary (total processed, succeeded, failed, duration) as a separate task. Because that write is journaled, it's a durable record of the job outcome that survives even if the process crashes immediately after — and the failed-item counts become the worklist for a targeted re-run rather than a full reprocess.


Next Steps