mirror of
https://github.com/hibiken/asynq.git
synced 2026-04-26 07:25:56 +03:00
[PR #550] [CLOSED] Improve performance of enqueueing tasks #1781
Labels
No labels
CLI
bug
designing
documentation
duplicate
enhancement
good first issue
good first issue
help wanted
idea
invalid
investigate
needs-more-info
performance
pr-welcome
pull-request
question
wontfix
work in progress
work in progress
work-around-available
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/asynq#1781
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/hibiken/asynq/pull/550
Author: @yousifh
Created: 9/25/2022
Status: ❌ Closed
Base:
master← Head:enqueue-sadd-cache-optimize📝 Commits (1)
11acdbaImprove performance of enqueueing tasks📊 Changes
2 files changed (+123 additions, -17 deletions)
View changed files
📝
internal/rdb/rdb.go(+75 -17)📝
internal/rdb/rdb_test.go(+48 -0)📄 Description
Shows a potential solution to #549
Create a map of queue names -> expiration dates in the RDB client. Every time we enqueue a task to queue X, cache queue X in the map and expire it after 10 secs. A mutex is used to protect the access, but there isn't a concern of lock contention as the clients will spend most of their time issuing network calls to enqueue tasks, and acquiring locks to check expiration is very fast.
The issue highlights the performance improvements but will re-post them here as well
All deployments were done in a normal k8s environment and metrics were measured through Datadog
Caveat:
This approach keeps the in-memory map of queues forever. It doesn't delete the entry when it expires. This is much simpler to implement, but if there is an app that enqueues tasks to millions of randomly named queues and the app never gets restarted, there is a potential memory leak. However that seems to be an unlikely use case of this library.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.