Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

UN-3996 [FIX] Stop WebSockets exhausting the Gunicorn thread pool (#2241)

Kirtiman Mishra3be7483bbcd1
diff --git a/backend/entrypoint.sh b/backend/entrypoint.sh
index 5d44345fd..20441c58f 100755
--- a/backend/entrypoint.sh
+++ b/backend/entrypoint.sh
@@ -29,11 +29,15 @@ if [ "$migrate" = true ]; then
.venv/bin/python manage.py migrate
fi
-# Configure Gunicorn based on --dev flag
+# Configure Gunicorn based on --dev flag.
+# Threads must exceed concurrent browser tabs — each open Socket.IO WebSocket
+# holds one thread for its lifetime. The pool spawns threads lazily, so a high
+# ceiling is free at idle.
gunicorn_args=(
--bind 0.0.0.0:8000
- --workers 2
- --threads 2
+ --workers "${GUNICORN_WORKERS:-2}"
+ --threads "${GUNICORN_THREADS:-512}"
+ --worker-class gthread
--log-level debug
--timeout 600
--access-logfile -
diff --git a/backend/sample.env b/backend/sample.env
index b57101813..700422d1a 100644
--- a/backend/sample.env
+++ b/backend/sample.env
@@ -7,6 +7,11 @@ CSRF_COOKIE_SECURE=False
# Default log level
DEFAULT_LOG_LEVEL="INFO"
+# Gunicorn tuning. GUNICORN_THREADS must exceed concurrent browser tabs —
+# each open Socket.IO WebSocket holds one thread for its lifetime.
+GUNICORN_WORKERS=2
+GUNICORN_THREADS=512
+
# Common
PATH_PREFIX="api/v1"