From a68d2fd95e9eb6ad179baac615783a00e511c0a0 Mon Sep 17 00:00:00 2001 From: Keshav Priyadarshi Date: Thu, 30 Apr 2026 20:35:30 +0530 Subject: [PATCH 1/2] fix: use shared cache backend across WSGI workers Signed-off-by: Keshav Priyadarshi --- vulnerablecode/settings.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/vulnerablecode/settings.py b/vulnerablecode/settings.py index 8ec5f6e31..e14c923cf 100644 --- a/vulnerablecode/settings.py +++ b/vulnerablecode/settings.py @@ -402,6 +402,18 @@ } +vcio_redis_host = env.str("VULNERABLECODE_REDIS_HOST", default=None) +vcio_redis_port = env.str("VULNERABLECODE_REDIS_PORT", default=None) + +if vcio_redis_host and vcio_redis_port: + CACHES = { + "default": { + "BACKEND": "django.core.cache.backends.redis.RedisCache", + "LOCATION": f"redis://{vcio_redis_host}:{vcio_redis_port}", + } + } + + # FederatedCode integration FEDERATEDCODE_VULNERABILITIES_REPO = env.str( From 61c4693b0cc5b37239e15dc4af0799b81634e31f Mon Sep 17 00:00:00 2001 From: Keshav Priyadarshi Date: Thu, 30 Apr 2026 20:54:32 +0530 Subject: [PATCH 2/2] feat: use additional worker count to indicate load factor Signed-off-by: Keshav Priyadarshi --- vulnerabilities/templates/pipeline_dashboard.html | 4 ++-- vulnerabilities/views.py | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/vulnerabilities/templates/pipeline_dashboard.html b/vulnerabilities/templates/pipeline_dashboard.html index 826c614ea..61c479126 100644 --- a/vulnerabilities/templates/pipeline_dashboard.html +++ b/vulnerabilities/templates/pipeline_dashboard.html @@ -86,13 +86,13 @@

Pipeline Dashboard

worker{{ additional|pluralize }} for the {{ queue_name }} queue."> - {% elif load_factor < 1 %} + {% elif additional < 1 %} {{ load_factor|floatformat:2 }} - {% elif load_factor < 1.6 %} + {% elif additional < 2 %} {{ load_factor|floatformat:2 }} diff --git a/vulnerabilities/views.py b/vulnerabilities/views.py index 371dcd217..3aff06768 100644 --- a/vulnerabilities/views.py +++ b/vulnerabilities/views.py @@ -59,8 +59,6 @@ PAGE_SIZE = 10 -CACHE_TIMEOUT = 60 * 5 - class VulnerableCodeView(View): """ @@ -965,11 +963,12 @@ def get_queryset(self): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) + cache_timeout = 60 * 10 load_per_queue = cache.get("load_per_queue") if load_per_queue is None: load_per_queue = compute_queue_load_factor() - cache.set("load_per_queue", load_per_queue, CACHE_TIMEOUT) + cache.set("load_per_queue", load_per_queue, cache_timeout) context["load_per_queue"] = load_per_queue context["active_pipeline_count"] = PipelineSchedule.objects.filter(is_active=True).count()