Workflows
Long-running jobs
Work that takes minutes to hours: accept, queue, report progress, notify when done.
What it is and why it exists
Research agents, document batches and fine-tunes don’t fit an HTTP request. Return 202 Accepted with a job ID, process in workers, persist progress, and let the client poll, subscribe (SSE/WebSocket) or receive a webhook.
Quick prototype
A request that hangs for four minutes.
In production, at scale
Job table with status, queue + workers, heartbeats and timeouts, cancellation, progress events, retries with idempotency, and result storage with expiry.
Vendors and tools
| Celery / ARQ / RQ / BullMQ | Job queues |
|---|---|
| Temporal / Inngest | Durable long jobs |
| Batch APIs | Discounted asynchronous LLM calls |
On AWS: SQS + Lambda or ECS workers; Step Functions; EventBridge for completion events.
How it fails
- Serverless function timeouts mid-job
- Jobs stuck “running” forever after a worker died
What the interviewer asks next
How do you detect a dead worker?
Heartbeats: the worker updates a timestamp every N seconds; a sweeper marks jobs with stale heartbeats as failed or re-queues them (visibility timeouts do this for queues).