Статья ещё не опубликована на языке Russian. Показана версия на English.
Durable Execution and Event-Driven Workflows: Systems Engineering Guide
Опубликовано
2 мин на чтение
Modern SaaS automation rarely fits inside a single 10-second HTTP request. Outbound campaigns fan out to thousands of recipients under provider rate limits, follow-up sequences sleep for hours waiting for a reply or payment event, and third-party APIs fail unpredictably.
Durable execution (pioneered by engines like Temporal) turns fragile cron-plus-queue glue code into deterministic, crash-proof stateful workflows that survive deploys, restarts, and outages cleanly.
Cron + Ad-Hoc Queues vs Durable Execution
| Dimension | Cron Polling + Ad-Hoc Job Queues | Durable Execution Workflows |
|---|---|---|
| Multi-step state | Scattered across DB status columns and partial flags | Single readable function with persisted event history |
| Long timers (hours/days) | Polled DB tables with clock drift and lock contention | Native durable timers waking on exact schedule |
| Crash recovery | Manual cleanup scripts and duplicate side effects | Deterministic replay resumes at exact pending step |
| External events (replies/payments) | Complex webhook state-machine joins | Typed Signals delivered directly to running workflow ID |
| Observability | Piecing together scattered worker logs | Complete per-execution timeline with inputs, retries, and stack traces |
Conceptual Durable Follow-Up Workflow
ts
export async function followUpSequenceWorkflow(input: {
recipientId: string;
waitMs: number;
}): Promise<"converted" | "replied" | "reminded" | "cancelled"> {
let replied = false;
let paid = false;
setHandler(customerRepliedSignal, () => {
replied = true;
});
setHandler(paymentConfirmedSignal, () => {
paid = true;
});
await sendInitialMessageActivity(input.recipientId);
const eventArrived = await condition(() => replied || paid, input.waitMs);
if (paid) return "converted";
if (replied) return "replied";
if (!eventArrived) {
await sendReminderActivity(input.recipientId);
return "reminded";
}
return "cancelled";
}
Curriculum: All Articles in This Track
- Durable Execution Fundamentals: Workflows, Activities, Event History, and Deterministic Replay
- Idempotency and Effectively-Once Side Effects in Distributed Messaging Systems
- Resilient Retries: Exponential Backoff, Jitter, Non-Retryable Errors, and DLQs
- Human-Timed Durable Workflows: Sleep Timers, External Signals, Queries, and Cancellation
- Rate Limiting, Token Buckets, and Provider Circuit Breakers for Outbound Messaging
- Fan-Out / Fan-In Batch Processing and Backpressure Without Overloading Downstream APIs
- Safe Workflow Versioning and Zero-Downtime Worker Deployments
- Production Webhook Pipelines: HMAC Verification, Fast Ack, Deduplication, and Ordering
- Engineering Reply-Aware Follow-Up Sequences and Conversational State Machines
Related Engineering Tracks
В этом разделе
Durable Execution Fundamentals: Workflows, Activities, Event History, and Deterministic ReplayIdempotency and Effectively-Once Side Effects in Distributed Messaging SystemsResilient Retries: Exponential Backoff, Jitter, Non-Retryable Errors, and DLQsHuman-Timed Durable Workflows: Sleep Timers, External Signals, Queries, and CancellationRate Limiting, Token Buckets, and Provider Circuit Breakers for Outbound MessagingFan-Out / Fan-In Batch Processing and Backpressure Without Overloading Downstream APIsSafe Workflow Versioning and Zero-Downtime Worker DeploymentsProduction Webhook Pipelines: HMAC Verification, Fast Ack, Deduplication, and OrderingEngineering Reply-Aware Follow-Up Sequences and Conversational State Machines
Было ли это полезно?