FrameworksPart 2
Kestrel Took 19 to 27 % More Time Than a Bare Socket at 1, 10 and 100 Concurrent Requests
A minimal Kestrel endpoint took 19 to 27 % longer than a bare socket listener at concurrency 1, 10 and 100, and allocated 2.4 to 3.2 times more.

In short
- A minimal Kestrel endpoint took 19 to 27 % more time than a bare socket listener at concurrency 1, 10 and 100 across four runs; in the official run the figure was 24.1 %, 23.6 % and 23.1 %.
- The expected widening with concurrency did not appear, so the hypothesis that the gap would grow disproportionately was falsified on this harness.
- Kestrel allocated about 3.1 times as many bytes at concurrency 1 and 10 and about 2.5 times at concurrency 100; the lower ratio comes from the raw arm's measured allocation per request rising at 100 (3.51 to 4.47 KB), while the Kestrel arm stayed at 10.84 to 11.14 KB; where in the process the extra bytes were allocated was not measured.
- The gap covers everything Kestrel does that the raw listener does not, and the measurement does not split it.
A minimal Kestrel endpoint took 19 to 27 % more time than a bare socket listener at concurrency 1, 10 and 100, and the ratio did not widen as concurrency rose. The hypothesis behind the benchmark was the opposite: that the gap would grow disproportionately with in-flight requests. It did not, in any of four runs.
Allocation tells a related story with one wrinkle. Kestrel allocated about 3.1 times as many bytes per operation at concurrency 1 and 10, and about 2.5 times at 100. The ratio fell at 100 because the raw arm’s measured allocation per request rose, while the Kestrel arm’s did not fall. Where the extra bytes were allocated was not measured.
What was compared
Part one of this series measured the pipeline the request enters next, one middleware at a time. This part measures what happens before that pipeline runs, with the handler reduced to nothing.
Arm A is a bare Socket listener. It accepts a connection, reads until it finds the end of the request head, writes a fixed 57 byte 200 OK with Connection: close, shuts down its sending side and closes. It does not parse the request line, route or build headers per request. Arm B is WebApplication.CreateBuilder with MapGet("/", () => Results.Ok()), with ClearProviders() called so that hosting’s per-request log lines are not part of the measurement. Its response is 111 bytes, because Kestrel adds Date and Server headers.
One client drives both arms. It is a hand-written Socket and NetworkStream client, with no HttpClient on either side. Every request opens a new connection, sends one GET with Connection: close, reads until the server closes, and resets the socket with linger 0. An operation issues 1, 10 or 100 of those requests at once through Task.WhenAll, set with [Params(1, 10, 100)], with [MemoryDiagnoser] attached. Because the client, the connection policy and the parameters are identical, the ratio between arms at each level is the comparable quantity.
The time ratio does not widen with concurrency
The official run, BenchmarkDotNet 0.15.8, reported these means with their error:
| Concurrency | A (raw) Mean | B (Kestrel) Mean | (B-A)/A, with interval |
|---|---|---|---|
| 1 | 26.06 ± 0.515 μs | 32.33 ± 0.566 μs | +24.1 % [+19.5, +28.8] |
| 10 | 153.29 ± 3.010 μs | 189.54 ± 3.407 μs | +23.6 % [+19.1, +28.4] |
| 100 | 1,433.95 ± 12.630 μs | 1,765.26 ± 19.163 μs | +23.1 % [+20.7, +25.5] |
Across the four runs the ratio ranged from +19.4 % to +27.3 %. The interval for concurrency 1 overlapped the interval for concurrency 100 in every run, and arm B was slower than arm A with no overlap in all twelve rows. The order of the three levels was not the same from run to run, so no trend is claimed in either direction.
The three levels are not the same kind of number. At concurrency 1 the mean is the latency of one request. At 10 and 100 it is the time for the whole burst to complete, so it amortises across the requests in flight and depends on how two cores are shared between client and server. Only the ratio is compared across levels. The 6.27 μs difference at concurrency 1 is a latency difference and is not extrapolated to the burst levels, where no per-request difference is derived.
Allocation per request
| Concurrency | A (raw) Allocated | B (Kestrel) Allocated | Ratio |
|---|---|---|---|
| 1 | 3.51 KB | 11.14 KB | 3.17× |
| 10 | 35.22 KB | 108.36 KB | 3.08× |
| 100 | 446.86 KB | 1,110.19 KB | 2.48× |
Per request in the official run, arm B allocated 11.14, 10.84 and 11.10 KB at concurrency 1, 10 and 100, and arm A allocated 3.51, 3.52 and 4.47 KB. Across the four runs, arm B stayed between 10.81 and 11.14 KB per request and the ratio was 3.08 to 3.20 at concurrency 1 and 10, and 2.43 to 2.51 at 100.
Garbage collection differs too. At concurrency 100 the Kestrel arm showed 3.9063 generation 2 collections per 1,000 operations in all four runs, and the raw arm showed none. The harness does not say why, and the cause is not attributed here.
Allocated is process-wide. It includes the client, the server and any background work that happened during the iteration, such as Kestrel’s heartbeat. The client code is identical in both arms, but its share is not a constant base independent of concurrency, so the ratio at concurrency 100 is not a pure Kestrel-versus-raw-listener ratio.
What the gap contains
Arm A does no HTTP parsing beyond finding \r\n\r\n. Arm B does everything Kestrel does: parsing, header building, routing, endpoint execution, its pipelines and connection management, and it writes 54 more bytes of response. The benchmark measures the sum of those differences. No breakdown inside Kestrel was measured, so this article does not say which part accounts for what share of the 19 to 27 %.
The reading that survives is narrower than the benchmark was built to support. In this harness, the Kestrel arm took 19 to 27 % more time than the raw arm at concurrency 1 (latency) and at 10 and 100 (burst completion time), with no measurable widening between levels. The raw arm’s time is the sum of the client, the raw listener, the kernel and the harness, and it was not split, so no share of it is attributed to any one of them.
Limits decide how far that travels. Client and server shared the same two cores, over loopback, so the client competed with the server for CPU. Every request used a new connection and Connection: close; keep-alive, HTTP/2 and TLS were not measured. Workstation GC was in use, and server GC was not tested. Two cores were pinned, and a --cpus quota, more than two cores and a graceful close were not measured. BenchmarkDotNet flagged two rows in the reproduction runs, both at concurrency 10, as possibly multimodal, and one run of the Kestrel arm at concurrency 1 recorded one exception in 16,384 operations whose source was not measured; the conclusion does not change with either.
To reproduce the comparison on a different stack, build a raw-listener arm beside the endpoint, keep one client for both, and read the (B-A)/A ratio at each concurrency level before reading the absolute numbers. Only a widening ratio would justify the original suspicion.
Measured on .NET SDK 10.0.401 / runtime 10.0.12 (Microsoft.AspNetCore.App 10.0.12), Linux (Ubuntu 24.04) arm64, inside the project’s Docker sandbox with --network none and --cpuset-cpus 0-1, so ProcessorCount was 2. The container had no CPU quota (cpu.max max 100000) and no memory limit (memory.max max), and used workstation GC. The harness was BenchmarkDotNet 0.15.8 with [MemoryDiagnoser]; the official run started on 1 October 2026 at 08 UTC, and three further runs gave the ranges quoted above. What this harness cannot see: loopback is not a real network, and neither keep-alive, TLS, HTTP/2 nor server GC was exercised.
Frequently asked
Questions this raises
Did the Kestrel overhead grow with concurrency?
No. The (B-A)/A time ratio was +24.1 %, +23.6 % and +23.1 % at concurrency 1, 10 and 100 in the official run, and the intervals for concurrency 1 and 100 overlapped in all four runs. No trend across levels is claimed.
What does the 19 to 27 % gap consist of?
Everything Kestrel does that the raw listener does not, such as request parsing, header building, routing, endpoint execution and connection management, plus a 111 byte response against 57 bytes. The harness measured the sum only, so no share is attributed to any single stage.
Do these numbers apply to a production Kestrel server?
Not directly. Every request opened a new connection with Connection close, over loopback, on two shared cores, with workstation GC. Keep-alive, HTTP/2, TLS, server GC and a real network were not measured.


