fix: use documented worker formula (2 * CPU + 1) in Docker image

This commit is contained in:
Benoit Chesneau 2026-01-23 19:13:47 +01:00
parent 469110d647
commit 4e656d3a91
3 changed files with 4 additions and 4 deletions

View File

@ -20,7 +20,7 @@ RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# GUNICORN_BIND - full bind address (default: [::]:8000, IPv4+IPv6) # GUNICORN_BIND - full bind address (default: [::]:8000, IPv4+IPv6)
# GUNICORN_HOST - bind host (default: [::]) # GUNICORN_HOST - bind host (default: [::])
# GUNICORN_PORT - bind port (default: 8000) # GUNICORN_PORT - bind port (default: 8000)
# GUNICORN_WORKERS - number of workers (default: number of CPUs) # GUNICORN_WORKERS - number of workers (default: 2 * CPU + 1)
# GUNICORN_ARGS - additional arguments (e.g., "--timeout 120") # GUNICORN_ARGS - additional arguments (e.g., "--timeout 120")
USER gunicorn USER gunicorn

View File

@ -15,9 +15,9 @@ if [ "${1:0:1}" = '-' ] || [ -z "${1##*:*}" ]; then
set -- --bind "$BIND" "$@" set -- --bind "$BIND" "$@"
fi fi
# Add workers if not specified - default to number of CPUs # Add workers if not specified - default to (2 * CPU_COUNT) + 1
if [[ ! " $* $GUNICORN_ARGS " =~ " --workers " ]] && [[ ! " $* $GUNICORN_ARGS " =~ " -w " ]] && [[ ! "$* $GUNICORN_ARGS" =~ --workers= ]] && [[ ! "$* $GUNICORN_ARGS" =~ -w= ]]; then if [[ ! " $* $GUNICORN_ARGS " =~ " --workers " ]] && [[ ! " $* $GUNICORN_ARGS " =~ " -w " ]] && [[ ! "$* $GUNICORN_ARGS" =~ --workers= ]] && [[ ! "$* $GUNICORN_ARGS" =~ -w= ]]; then
WORKERS="${GUNICORN_WORKERS:-$(nproc)}" WORKERS="${GUNICORN_WORKERS:-$(( 2 * $(nproc) + 1 ))}"
set -- --workers "$WORKERS" "$@" set -- --workers "$WORKERS" "$@"
fi fi

View File

@ -27,7 +27,7 @@ docker run -p 8000:8000 -v $(pwd):/app ghcr.io/benoitc/gunicorn app:app
| `GUNICORN_BIND` | Full bind address | `[::]:8000` (IPv4+IPv6) | | `GUNICORN_BIND` | Full bind address | `[::]:8000` (IPv4+IPv6) |
| `GUNICORN_HOST` | Bind host | `[::]` | | `GUNICORN_HOST` | Bind host | `[::]` |
| `GUNICORN_PORT` | Bind port | `8000` | | `GUNICORN_PORT` | Bind port | `8000` |
| `GUNICORN_WORKERS` | Number of workers | Number of CPUs | | `GUNICORN_WORKERS` | Number of workers | `(2 * CPU) + 1` |
| `GUNICORN_ARGS` | Additional arguments | (none) | | `GUNICORN_ARGS` | Additional arguments | (none) |
### With Configuration ### With Configuration