Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
apt-get update && apt-get install -y --no-install-recommends \
libpq5 \
curl \
wget \
&& apt-get upgrade -y

# Create non-root user for security
Expand Down Expand Up @@ -110,7 +109,6 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
apt-get update && apt-get install -y --no-install-recommends \
libpq5 \
curl \
wget \
&& apt-get upgrade -y

# Create non-root user for security
Expand All @@ -121,7 +119,8 @@ RUN groupadd -r appuser && \
ENV PYTHONUNBUFFERED=1 \
PYTHONPATH=/app/src \
PATH="/app/.venv/bin:$PATH" \
VIRTUAL_ENV=/app/.venv
VIRTUAL_ENV=/app/.venv \
DJANGO_Q_WORKERS=1

WORKDIR /app

Expand Down
7 changes: 6 additions & 1 deletion src/gunicorn_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,18 @@
# A positive integer. Generally set in the 1-5 seconds range.
#

workers = 3
workers = 1
threads = 2
worker_class = "gthread"
worker_connections = 1000
timeout = 30
keepalive = 2
worker_tmp_dir = "/dev/shm"

# Memory leak mitigation - restart workers after handling N requests
max_requests = 1000
max_requests_jitter = 50

# preload_app - Load application code before forking worker processes.
# This conserves memory and speeds up server boot times by loading
# the Django application once in the main process, then forking
Expand Down
2 changes: 1 addition & 1 deletion src/settings/components/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
# Django-Q2 configuration (sync mode for testing, use redis/orm in production)
Q_CLUSTER = {
"name": "operationcode",
"workers": 2,
"workers": config("DJANGO_Q_WORKERS", default=1, cast=int),
"timeout": 60,
"retry": 120,
"queue_limit": 50,
Expand Down