Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redis having 100 changes in 300 seconds even when idle #126

Open
anantshri opened this issue Dec 29, 2022 · 0 comments
Open

Redis having 100 changes in 300 seconds even when idle #126

anantshri opened this issue Dec 29, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@anantshri
Copy link

TL:DR; our taskmanager hits redis every 0.2 seconds to check for pending tasks we can reduce it by adding a parameter in config/settings/base.py

diff --git a/config/settings/base.py b/config/settings/base.py
index b66483a..c35a9b1 100644
--- a/config/settings/base.py
+++ b/config/settings/base.py
@@ -349,6 +349,7 @@ Q_CLUSTER = {
     'retry': 20*60,
     'recycle': 1,
     'max_attempts': 5,
+    "guard_cycle": 10,
     'timeout': 19*60,
     'compress': True,
     'save_limit': 25,

Long Details

I keep getting these messages after regular interval even when nothing is happening on application.

redis_1          | 2022-12-29T11:13:04.096568776Z 1:M 29 Dec 2022 11:13:04.096 * 100 changes in 300 seconds. Saving...
redis_1          | 2022-12-29T11:13:04.097868021Z 1:M 29 Dec 2022 11:13:04.097 * Background saving started by pid 280
redis_1          | 2022-12-29T11:13:04.101346575Z 280:C 29 Dec 2022 11:13:04.101 * DB saved on disk
redis_1          | 2022-12-29T11:13:04.103382853Z 280:C 29 Dec 2022 11:13:04.103 * RDB: 0 MB of memory used by copy-on-write
redis_1          | 2022-12-29T11:13:04.198490918Z 1:M 29 Dec 2022 11:13:04.198 * Background saving terminated with success

This led me to check what is being written on redis using redis-cli monitor on running redis instance using

docker exec -it <instanceID> redis-cli monitor

I was able to identify these messages

1672315334.573630 [0 172.19.0.10:47526] "BLPOP" "django_q:Backend:q" "1"
1672315334.706288 [0 172.19.0.10:47516] "SET" "django_q:Backend:cluster:175a55d3-174a-424f-ad30-c830f40d3c92" ".eJxVUM0uQ0EURkurSkUkJfETu9o0RWJlhQ2zkKAbidz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K_SWDlYeaB2OevVRbUP-dW6SQ:1pArbz:WNNY_Cz4s_66HXtqBZx8S2C3WV_Td5z_7smLNWmBZkw" "EX" "3"

These messages point to django-q as the culprit, looking at the closed issues on the repository found Koed00/django-q#359 matching my scenarios and that points to a bug paperless-ngx/paperless-ngx#1084 which points to paperless-ngx/paperless-ngx#1084 (comment) comment and confirms suspicion. There is an associated pull request : https://github.com/paperless-ngx/paperless-ngx/pull/1091/files and Documentation https://django-q.readthedocs.io/en/latest/configure.html#guard-cycle

https://github.com/Pithus/bazaar/blob/master/config/settings/base.py#L346 This is our config file

I have reduced this to 5 seconds and I see a slightly lower cpu usage but I want someone else to test this and confirm if this is the case.

@U039b U039b added the enhancement New feature or request label Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants