asynq
Simple, reliable, and efficient distributed task queue in Go
Asynq is a Go library for running slow tasks like sending emails or resizing images in the background using Redis as a queue, so your web app stays fast and work can be spread across multiple machines.
Asynq is a Go library for offloading work to background jobs. Instead of doing something time-consuming (like sending an email or resizing an image) directly inside a web request, you create a task describing the work and put it on a queue. Separate worker processes pick tasks off the queue and do the actual work. This pattern keeps your application responsive and lets you spread the processing load across multiple machines.
It uses Redis as the storage layer for the queue. Redis is a fast, in-memory data store that Asynq uses to hold pending and active tasks. Because Redis stores the queue, tasks survive application restarts, and multiple worker servers can pull from the same queues to share the load.
The feature list is substantial. Tasks that fail can be retried automatically, and if a worker process crashes while handling a task, that task is recovered and rescheduled. You can assign priorities to queues, either by weight (high-priority queues get a larger share of workers) or strict ordering (all tasks in a higher-priority queue are processed before touching lower ones). Tasks can be scheduled to run at a specific future time, given deadlines or timeouts, or deduplicated so the same work is not enqueued twice. You can also group multiple related tasks and have them processed together as a batch.
For observability, Asynq integrates with Prometheus for metrics, and ships with both a web UI and a command-line tool for inspecting and managing queues and individual tasks. Queues can be paused to temporarily stop processing without losing any pending work.
The library is described as relatively stable and is pre-1.0, so the API may still change before a stable release. Redis Cluster is partially supported but some features may not be compatible.
Where it fits
- Offload email delivery from a web request to a background worker so the user gets an instant response
- Schedule a nightly report job to run at a specific time each day without a cron server
- Deduplicate file-processing tasks so the same upload is never processed twice even if the user clicks twice
- Set up priority queues so urgent payment jobs are always processed before low-priority analytics tasks