Skip to content
Open
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
14 changes: 10 additions & 4 deletions backend/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,18 @@ 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 the number of concurrently connected browser tabs: the
# Socket.IO WSGI app runs with async_mode="threading", so each open WebSocket
# holds one gthread pool thread for that connection's lifetime, not just for a
# request. 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
--log-level debug
--workers "${GUNICORN_WORKERS:-2}"
--threads "${GUNICORN_THREADS:-512}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kirtimanmishrazipstack a default 512 threads might eatup your local machine memory and cpu. I believe that is why it was left 2 deliberately in the beginning. @muhammad-ali-e would be better person to answer.

What I would suggest is a bit more conservative default value something like 8 or 16.

Also if any other similar services need such a configurability please do include that as well.

--worker-class gthread
--worker-connections "${GUNICORN_WORKER_CONNECTIONS:-1000}"
Comment thread
kirtimanmishrazipstack marked this conversation as resolved.
--log-level "${DEFAULT_LOG_LEVEL:-INFO}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kirtimanmishrazipstack I will suggest using a different env for this log level. There might be places when we need gunicorn at debug log level but not the application

--timeout 600
--access-logfile -
)
Expand Down
9 changes: 8 additions & 1 deletion backend/sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ DJANGO_SETTINGS_MODULE='backend.settings.dev'
SESSION_COOKIE_SECURE=False
CSRF_COOKIE_SECURE=False

# Default log level
# Default log level. Also drives Gunicorn's --log-level.
DEFAULT_LOG_LEVEL="INFO"

# Gunicorn tuning. GUNICORN_THREADS must exceed the number of concurrently
# connected browser tabs — each open Socket.IO WebSocket holds one thread for
# its whole lifetime.
# GUNICORN_WORKERS=2
# GUNICORN_THREADS=512
# GUNICORN_WORKER_CONNECTIONS=1000

# Common
PATH_PREFIX="api/v1"

Expand Down
Loading