explaingit

hibiken/asynq

13,271GoAudience · developerComplexity · 3/5Setup · moderate

TLDR

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.

Mindmap

mindmap
  root((asynq))
    How it works
      Task queue
      Worker processes
      Redis storage
    Reliability
      Auto-retry on failure
      Crash recovery
      Task deduplication
    Scheduling
      Delayed tasks
      Deadlines
      Cron-style scheduling
    Priority
      Weighted queues
      Strict ordering
    Observability
      Prometheus metrics
      Web UI
      CLI tool
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Offload email delivery from a web request to a background worker so the user gets an instant response

USE CASE 2

Schedule a nightly report job to run at a specific time each day without a cron server

USE CASE 3

Deduplicate file-processing tasks so the same upload is never processed twice even if the user clicks twice

USE CASE 4

Set up priority queues so urgent payment jobs are always processed before low-priority analytics tasks

Tech stack

GoRedisPrometheus

Getting it running

Difficulty · moderate Time to first run · 30min

Requires a running Redis instance, Redis Cluster support is partial.

In plain English

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.

Copy-paste prompts

Prompt 1
Set up an Asynq worker in Go that sends emails in the background and retries automatically if the mail server is down
Prompt 2
Show me how to schedule a recurring Asynq task to run every night at midnight using Go
Prompt 3
Configure Asynq with two priority queues, one critical and one default, so critical tasks always run first
Prompt 4
Add Prometheus metrics to an Asynq worker so I can track queue depth and task failure rate in Grafana
Prompt 5
Use the Asynq web UI to inspect and retry failed tasks without writing any code
Open on GitHub → Explain another repo

← hibiken on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.