perf: allow disabling websocket per-message-deflate (#28613)

With delta streaming most websocket frames are tiny per-token deltas, and
per-message-deflate pays zlib work on every outgoing frame per subscriber for
near-zero gain there; under heavy streaming that shows up as measurable server
CPU. The frames that still benefit are the rare large ones (final message,
sources), and even a 100k token message is only a few hundred KB uncompressed,
which any network delivers without noticeable delay.

UVICORN_WS_PER_MESSAGE_DEFLATE=false (default true, current behavior) disables
the extension in every entry point: open-webui serve and dev, start.sh both
invocations, start_windows.bat and dev.sh. Verified against a running
instance: with the flag off the server declines the client-offered
permessage-deflate extension, with defaults it still negotiates it.
This commit is contained in:
Classic298 authored and GitHub committed 2026-08-24 18:46:07 -04:00
1 parent 97466deea1
commit bf08835d6f
5 files changed
+13 -5

No files matched your search

+2 -2
View File
@@ -72,7 +72,7 @@ if [[ -n "${SPACE_ID:-}" ]]; then
if [[ -n "${ADMIN_USER_EMAIL:-}" && -n "${ADMIN_USER_PASSWORD:-}" ]]; then
echo "Creating admin user for Space..."
WEBUI_SECRET_KEY="${WEBUI_SECRET_KEY:-}" \
uvicorn open_webui.main:app --host "$HOST" --port "$PORT" --forwarded-allow-ips "${FORWARDED_ALLOW_IPS:-*}" &
uvicorn open_webui.main:app --host "$HOST" --port "$PORT" --forwarded-allow-ips "${FORWARDED_ALLOW_IPS:-*}" --ws-per-message-deflate "${UVICORN_WS_PER_MESSAGE_DEFLATE:-true}" &
webui_pid=$!
echo "Waiting for server to become healthy..."
@@ -102,7 +102,7 @@ UVICORN_WORKERS="${UVICORN_WORKERS:-1}"
if [[ "$#" -gt 0 ]]; then
ARGS=("$@")
else
ARGS=(--workers "$UVICORN_WORKERS")
ARGS=(--workers "$UVICORN_WORKERS" --ws-per-message-deflate "${UVICORN_WS_PER_MESSAGE_DEFLATE:-true}")
fi
exec env WEBUI_SECRET_KEY="${WEBUI_SECRET_KEY:-}" \