[PR #254] [MERGED] Replaced blocking KEYS command to non-blocking SCAN #689

Closed
opened 2026-03-02 06:05:11 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hibiken/asynq/pull/254
Author: @disc
Created: 3/20/2021
Status: Merged
Merged: 3/20/2021
Merged by: @hibiken

Base: masterHead: replace-keys-to-scan-command


📝 Commits (1)

  • ed58200 Replaced blocking KEYS XXX:* command to non-blocking SCAN XXX:*

📊 Changes

1 file changed (+11 additions, -3 deletions)

View changed files

📝 internal/rdb/inspect.go (+11 -3)

📄 Description

I've noticed that asynqmon makes KEYS queuename:* redis calls every a few seconds. But KEYS redis command is blocking and could affect production redis server.
I suggest to replace KEYS to SCAN command - it will be more safest way to iterate all keys and get their memory usage.

More details: https://redis.io/commands/KEYS

Warning: consider KEYS as a command that should only be used in production environments with extreme care. It may ruin performance when it is executed against large databases. This command is intended for debugging and special operations, such as changing your keyspace layout. Don't use KEYS in your regular application code. If you're looking for a way to find keys in a subset of your keyspace, consider using SCAN or sets.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hibiken/asynq/pull/254 **Author:** [@disc](https://github.com/disc) **Created:** 3/20/2021 **Status:** ✅ Merged **Merged:** 3/20/2021 **Merged by:** [@hibiken](https://github.com/hibiken) **Base:** `master` ← **Head:** `replace-keys-to-scan-command` --- ### 📝 Commits (1) - [`ed58200`](https://github.com/hibiken/asynq/commit/ed582000ad3adf891674e0a8065ba05b3e8aaa9d) Replaced blocking `KEYS XXX:*` command to non-blocking `SCAN XXX:*` ### 📊 Changes **1 file changed** (+11 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `internal/rdb/inspect.go` (+11 -3) </details> ### 📄 Description I've noticed that [asynqmon](https://github.com/hibiken/asynqmon) makes `KEYS queuename:*` redis calls every a few seconds. But [KEYS](https://redis.io/commands/keys) redis command is blocking and could affect production redis server. I suggest to replace KEYS to [SCAN](https://redis.io/commands/scan) command - it will be more safest way to iterate all keys and get their memory usage. More details: https://redis.io/commands/KEYS > Warning: consider KEYS as a command that should only be used in production environments with extreme care. It may ruin performance when it is executed against large databases. This command is intended for debugging and special operations, such as changing your keyspace layout. Don't use KEYS in your regular application code. If you're looking for a way to find keys in a subset of your keyspace, consider using SCAN or sets. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-02 06:05:11 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asynq#689
No description provided.