# Task Queues That Scale Infinitely

> Distributed task processing with automatic retries, priority queues, and intelligent scheduling. Handle millions of jobs per second with durable execution, dead letter queues, and sub-100ms latency.

Canonical: https://tasks.do/

## In code

```ts
import { Tasks } from 'tasks.do'

// Durable task queue with priority and retries
const EmailQueue = Tasks.queue('emails', {
  concurrency: 1000,
  retry: { maxAttempts: 3, backoff: 'exponential' }
})

await EmailQueue.enqueue({ to: user.email, priority: 'high' })

EmailQueue.process(async job => await sendEmail(job.data))

// Intelligent error handling
on.Task.failed($ => {
  if ($.data.attempts >= 3) $.Task.send.DeadLetter({ reason: $.data.error })
})
```

## Frequently asked questions

### How do tasks.do workflows differ from traditional job queues?

Tasks.do uses declarative TypeScript with automatic priority scheduling, intelligent retries, and durable execution. Traditional queues require manual setup of Redis/RabbitMQ/SQS, connection management, and retry logic. Tasks.do provides priority queues, dead letter queues, scheduled jobs, rate limiting, and concurrency control out of the box. Jobs are durable—server restarts or crashes never lose queued work. Full observability with metrics, traces, and logs included.

### What happens if a task fails?

Automatic retry with configurable strategies: exponential backoff (default 100ms to 1hr), linear, or custom intervals. Failed tasks move to dead letter queues after max attempts for manual inspection and reprocessing. Define custom retry policies per job type, fallback strategies for specific errors, and compensation logic for partial failures. State persisted before each attempt—never lose progress even with catastrophic failures. Full error context captured for debugging.

### Can tasks run for hours or days?

Yes. Durable execution with automatic state persistence means tasks can run indefinitely without consuming resources while waiting. Schedule tasks for future execution (days, weeks, months ahead), wait for external events or webhooks, pause for human approvals, or implement complex workflows with multiple stages. No timeouts on task execution—handle long-running batch processes, data migrations, or multi-day workflows with ease.

### How do I test task queues?

Full local testing with Vitest or Jest. Mock external services, simulate failures at any step, and validate retry logic deterministically. Time-travel debugging lets you inspect task state at any point in execution. Fast-forward scheduled tasks, trigger failure scenarios, and verify behavior under all conditions before deploying to production. Integration tests run against isolated edge environments with production parity.

### Can AI agents optimize task processing?

Yes. AI agents monitor queue metrics (depth, latency, failure rates) and automatically adjust concurrency, batching, and priority levels. Agents can restructure task pipelines, suggest better retry strategies, identify bottlenecks, and optimize resource allocation based on patterns. Task definitions are semantic objects—agents understand business context and can refactor queues for better performance while maintaining correctness.

## Part of Platform.do

tasks.do is one of the primitives of Platform.do, in the Workflows layer (triggers, steps and functions). Every .do shares one grammar, Business-as-Code, and one SDK.

- What is Business-as-Code? https://platform.do/business-as-code
- Platform.do: https://platform.do/
- Docs: https://docs.platform.do
