Skip to content

[Feature Request] Support for Group-based Sequential Processing (Serialization by Key) #1090

@nhd98z

Description

@nhd98z

Is your feature request related to a problem? Please describe.
I'm facing a race condition issue when processing tasks that share a specific resource constraint (e.g., tasks affecting the same wallet_address and chain_id).

Currently, asynq allows controlling global concurrency, but it doesn't seem to support "Partitioned Concurrency"—where tasks are executed sequentially per entity (same key) but concurrently across different entities.

For example:

  • Task A1 and Task A2 (both for User A) are enqueued.
  • Task B1 (for User B) is enqueued.
  • I want Task B1 to run in parallel with Task A1.
  • However, Task A2 must wait until Task A1 completes.

Currently, if multiple workers pick up Task A1 and Task A2 simultaneously, we encounter state conflicts.

Describe the solution you'd like
I would like to propose adding a Group or SerializationKey option when enqueuing a task.
The scheduler/processor should ensure that for any given Key, only one task is being processed at a time across all workers.

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions