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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ENV PYTHONUNBUFFERED 1

WORKDIR /app

RUN apk add --no-cache gcc musl-dev python3-dev libffi-dev
RUN apk add --no-cache gcc musl-dev python3-dev libffi-dev openssl-dev

COPY ./requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
Expand Down
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ services:
- /etc/letsencrypt/live/diningfee.iiti.ac.in/privkey.pem:/etc/letsencrypt/live/diningfee.iiti.ac.in/privkey.pem
env_file:
- ./.env
environment:
- GUNICORN_WORKERS=9
- GUNICORN_THREADS=4
- GUNICORN_TIMEOUT=300

nginx:
build: ./nginx
Expand Down
13 changes: 12 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,15 @@ python manage.py migrate --noinput
python manage.py collectstatic --noinput

# Start server
gunicorn messWebsite.wsgi:application --bind 0.0.0.0:8000 --workers=16 --preload --timeout 300
# Counts are env-tunable (see docker-compose.yml). gthread + --max-requests keep
# memory bounded; the previous 16 sync workers were OOM-killed under load.
gunicorn messWebsite.wsgi:application \
--bind 0.0.0.0:8000 \
--worker-class=gthread \
--workers="${GUNICORN_WORKERS:-3}" \
--threads="${GUNICORN_THREADS:-4}" \
--timeout="${GUNICORN_TIMEOUT:-300}" \
--graceful-timeout=30 \
--max-requests=1000 \
--max-requests-jitter=100 \
--preload
7 changes: 6 additions & 1 deletion messWebsite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,14 @@
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
"OPTIONS": {
# Wait up to 30s for the write lock instead of failing fast with
# "database is locked" under concurrent writes.
"timeout": 30,
"transaction_mode": "IMMEDIATE",
},
}
}
DATABASE_OPTIONS = {"timeout": 30}


# DATABASES = {
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ django-cloudinary-storage==0.3.0
gunicorn==23.0.0
whitenoise==6.4.0
django-cors-headers==4.7.0
PyJWT[crypto]==2.10.1
Loading