From 10db6cbaefb8cc5c75c3862eee1a82e581c4b255 Mon Sep 17 00:00:00 2001 From: Sebastian Kreft <911768+sk-@users.noreply.github.com> Date: Sat, 17 May 2025 10:00:41 -0400 Subject: [PATCH] chore: improve uvicorn settings In this PR we disable the access log and the `ProxyHeaderMiddleware` (https://www.uvicorn.org/deployment/?h=proxyheaders#proxies-and-forwarded-headers). Disable logging is recommended in point 3 of the General Test Requirements (https://github.com/TechEmpower/FrameworkBenchmarks/wiki/Project-Information-Framework-Tests-Overview#general-test-requirements) and has been done for other python tests like in https://github.com/TechEmpower/FrameworkBenchmarks/pull/9844/files. The ProxyHeadersMiddleware is enabled by default (trusting localhost) and adds considerable latency. As such it should be disabled if not required by test requirements. Enabling these flags increases performance (req/s) by 85% as seen in the numbers below ``` -- Before wrk http://localhost:8000/async Running 10s test @ http://localhost:8000/async 2 threads and 10 connections Thread Stats Avg Stdev Max +/- Stdev Latency 268.56us 36.54us 3.49ms 96.57% Req/Sec 18.34k 408.35 18.84k 91.58% 368739 requests in 10.10s, 49.23MB read Requests/sec: 36508.05 Transfer/sec: 4.87MB -- After wrk http://localhost:8000/async Running 10s test @ http://localhost:8000/async 2 threads and 10 connections Thread Stats Avg Stdev Max +/- Stdev Latency 143.21us 46.20us 2.00ms 98.02% Req/Sec 33.97k 1.16k 36.29k 82.67% 682461 requests in 10.10s, 91.12MB read Requests/sec: 67570.84 Transfer/sec: 9.02MB ``` --- frameworks/Python/fastapi/fastapi-uvicorn-orjson.dockerfile | 2 +- frameworks/Python/fastapi/fastapi-uvicorn.dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frameworks/Python/fastapi/fastapi-uvicorn-orjson.dockerfile b/frameworks/Python/fastapi/fastapi-uvicorn-orjson.dockerfile index 35e6b7d0030..59a6e040cd0 100644 --- a/frameworks/Python/fastapi/fastapi-uvicorn-orjson.dockerfile +++ b/frameworks/Python/fastapi/fastapi-uvicorn-orjson.dockerfile @@ -15,4 +15,4 @@ COPY . ./ EXPOSE 8080 -CMD uvicorn app:app --host 0.0.0.0 --port 8080 --workers $(nproc) --log-level error +CMD uvicorn app:app --host 0.0.0.0 --port 8080 --workers $(nproc) --log-level error --no-access-log --no-proxy-headers diff --git a/frameworks/Python/fastapi/fastapi-uvicorn.dockerfile b/frameworks/Python/fastapi/fastapi-uvicorn.dockerfile index 7da0ea40ce3..115104e3e49 100644 --- a/frameworks/Python/fastapi/fastapi-uvicorn.dockerfile +++ b/frameworks/Python/fastapi/fastapi-uvicorn.dockerfile @@ -15,4 +15,4 @@ COPY . ./ EXPOSE 8080 -CMD uvicorn app:app --host 0.0.0.0 --port 8080 --workers $(nproc) --log-level error +CMD uvicorn app:app --host 0.0.0.0 --port 8080 --workers $(nproc) --log-level error --no-access-log --no-proxy-headers