Skip to content

chore: improve uvicorn settings #9900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2025

Conversation

sk-
Copy link
Contributor

@sk- sk- commented May 17, 2025

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

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
```
@msmith-techempower msmith-techempower merged commit 02db245 into TechEmpower:master May 20, 2025
4 checks passed
litongjava pushed a commit to litongjava/FrameworkBenchmarks that referenced this pull request May 30, 2025
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
```

Co-authored-by: Sebastian Kreft <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants