Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
A

asynq

> 数据库
Open source

Simple, reliable, and efficient distributed task queue in Go

13.6K stars0 likes4 views
WebsiteGitHub

asynq: a distributed task queue for Go

asynq puts tasks in Redis and runs them in a worker process, with delay and retry.

Install

Add the module. Redis has to be running first.

go get github.com/hibiken/asynq

Use

Enqueue a task whose type name matches the handler you register.

client := asynq.NewClient(asynq.RedisClientOpt{Addr: "localhost:6379"})
client.Enqueue(asynq.NewTask("email:send", []byte(`{"to":"[email protected]"}`)))

Limits

It does not ship Redis. If the task type does not match a handler, the task fails.

Next

  • Go data structures: gods

About

Simple, reliable, and efficient distributed task queue in Go

Simple, reliable & efficient distributed task queue in Go

Asynq is a Go library for queueing tasks and processing them asynchronously with workers. It's backed by Redis and is designed to be scalable yet easy to get started.

Highlevel overview of how Asynq works:

  • Client puts tasks on a queue
  • Server pulls tasks off queues and starts a worker goroutine for each task
  • Tasks are processed concurrently by multiple workers

Task queues are used as a mechanism to distribute work across multiple machines. A system can consist of multiple worker servers and brokers, giving way to high availability and horizontal scaling.

Example use case

Features

  • Guaranteed at least one execution of a task
  • Scheduling of tasks
  • Retries of failed tasks
  • Automatic recovery of tasks in the event of a worker crash
  • Weighted priority queues
  • Strict priority queues
  • Low latency to add a task since writes are fast in Redis
  • De-duplication of tasks using unique option
  • Allow timeout and deadline per task
  • Allow aggregating group of tasks to batch multiple successive operations
  • Flexible handler interface with support for middlewares
  • Ability to pause queue to stop processing tasks from the queue
  • Periodic Tasks
  • Support Redis Sentinels for high availability
  • Integration with Prometheus to collect and visualize queue metrics
  • Web UI to inspect and remote-control queues and tasks
  • CLI to inspect and remote-control queues and tasks

Stability and Compatibility

Status: The library relatively stable and is currently undergoing moderate development with less frequent breaking API changes.

☝️ Important Note: Current major version is zero (v0.x.x) to accommodate rapid development and fast iteration while getting early feedback from users (feedback on APIs are appreciated!). The public API could change without a major version update before v1.0.0 release.

Redis Cluster Compatibility

Some of the lua scripts in this library may not be compatible with Redis Cluster.

Sponsoring

If you are using this package in production, please consider sponsoring the project to show your support!

Quickstart

Make sure you have Go installed (download). The last two Go versions are supported (See https://go.dev/dl).

Initialize your project by creating a folder and then running go mod init github.com/your/repo (learn more) inside the folder. Then install Asynq library with the go get command:

bash
go get -u github.com/hibiken/asynq

Make sure you're running a Redis server locally or from a Docker container. Version 4.0 or higher is required.

Next, write a package that encapsulates task creation and task handling.

…

In your application code, import the above package and use Client to put tasks on queues.

…

Next, start a worker server to process these tasks in the background. To start the background workers, use Server and provide your Handler to process the tasks.

You can optionally use ServeMux to create a handler, just as you would with net/http Handler.

…

For a more detailed walk-through of the library, see our Getting Started guide.

To learn more about asynq features and APIs, see the package godoc.

Web UI

Asynqmon is a web based tool for monitoring and administrating Asynq queues and tasks.

Here's a few screenshots of the Web UI:

Queues view

Tasks view

Metrics view

Settings and adaptive dark mode

For details on how to use the tool, refer to the tool's README.

Command Line Tool

Asynq ships with a command line tool to inspect the state of queues and tasks.

To install the CLI tool, run the following command:

bash
go install github.com/hibiken/asynq/tools/asynq@latest

Here's an example of running the asynq dash command:

For details on how to use the tool, refer to the tool's README.

Contributing

We are open to, and grateful for, any contributions (GitHub issues/PRs, feedback on Gitter channel, etc) made by the community.

Please see the Contribution Guide before contributing.

License

Copyright (c) 2019-present Ken Hibino and Contributors. Asynq is free and open-source software licensed under the MIT License. Official logo was created by Vic Shóstak and distributed under Creative Commons license (CC0 1.0 Universal).

Issues· 293 open

View all issuesOpen on GitHub
  • #661

    [BUG] GetQueueInfo doesn't return expected errors

    bugUpdated Oct 1, 2026
  • #1166

    [BUG] EnqueueContext loses underlying Redis errors returned by Lua scripts

    bugUpdated Sep 29, 2026
  • #1160

    Inspector.GetQueueInfo is O(#groups) and blocks Redis for seconds when a queue has many aggregation groups

    Updated Sep 9, 2026
  • #1173

    [FEATURE REQUEST] Support headers in Task metadata (e.g., OpenTelemetry context propagation)

    enhancementUpdated Aug 2, 2026
  • #515

    [FEATURE REQUEST] Set TTL on scheduler_history key

    bugUpdated Jul 22, 2026
  • #1052

    [FEATURE REQUEST] Need second level cron spec support

    enhancementUpdated Jul 21, 2026
  • #1086

    Clarify which Lua scripts are incompatible with Redis Cluster

    Updated Jul 16, 2026
  • #1146

    [BUG] asynq stats: redis eval error: attempt to perform arithmetic on local 'bytes' (a boolean value)

    bugUpdated Jul 16, 2026
  • #1167

    [BUG] ResultWriter.Write creates an orphan task hash when the task no longer exists

    bugUpdated Jul 16, 2026
  • #1162

    Unique(TTL < 1s) silently creates permanent lock due to int(ttl.Seconds()) truncation to 0

    Updated Jul 9, 2026

> Tags

Goasynchronous-tasksbackground-jobsgogolang

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedOct 2, 2026
Category数据库
PricingOpen source
WebsiteGitHub

> Related tools

G
gods
GoDS (Go Data Structures) - Sets, Lists, Stacks, Maps, Trees, Queues, and much more