Skip to content

Commit

Permalink
set PROMETHEUS_MULTIPROC_DIR env var (#2956)
Browse files Browse the repository at this point in the history
We recently upgraded to Gunicorn for inference (multi-proc), which broke
our prometheus stats and we got strange drops (see
trallnag/prometheus-fastapi-instrumentator#50
). For multi process model setting `PROMETHEUS_MULTIPROC_DIR` is
required, see
[here](https://github.com/prometheus/client_python/blob/master/README.md#multiprocess-mode-eg-gunicorn).
  • Loading branch information
andreaskoepf committed Apr 28, 2023
1 parent f1da07a commit 67499fd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions docker/inference/Dockerfile.server
Expand Up @@ -37,6 +37,7 @@ ENV PATH="${PATH}:${APP_LIBS}/bin"
ENV PYTHONPATH="${PYTHONPATH}:${APP_LIBS}"

ENV PORT="8080"
ENV PROMETHEUS_MULTIPROC_DIR="/tmp/oasst-inference-prometheus-metrics"

RUN adduser \
--disabled-password \
Expand Down
3 changes: 3 additions & 0 deletions inference/server/server_main.sh
Expand Up @@ -4,8 +4,11 @@ gunicorn_workers=${GUNICORN_WORKERS:-1}

# if 1 worker, stay with uvicorn
if [ $gunicorn_workers -eq 1 ]; then
unset PROMETHEUS_MULTIPROC_DIR
uvicorn main:app --host 0.0.0.0 --port "$PORT"
else
if [ -d "${PROMETHEUS_MULTIPROC_DIR}" ]; then rm -rf "${PROMETHEUS_MULTIPROC_DIR}"; fi
mkdir -p "${PROMETHEUS_MULTIPROC_DIR}"
port=${PORT:-8080}
gunicorn main:app --workers $gunicorn_workers --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:$port
fi

0 comments on commit 67499fd

Please sign in to comment.