Skip to content

Commit c3dd63f

Browse files
Copilottdykstra
andauthored
Show Kestrel overview feature list for .NET 8+ and move memory management to dedicated article (#36443)
* Initial plan * Create memory management article and update Kestrel overview Co-authored-by: tdykstra <[email protected]> * Address code review feedback for memory management article Co-authored-by: tdykstra <[email protected]> * Address code review feedback and fix moniker ranges Co-authored-by: tdykstra <[email protected]> * Fix moniker range usage to avoid duplicate H2 headers Co-authored-by: tdykstra <[email protected]> * Fix moniker ranges to eliminate duplicate headers Co-authored-by: tdykstra <[email protected]> * Replace not-latest-version include with not-latest-version-without-not-supported-content Co-authored-by: tdykstra <[email protected]> * Revert include file change in memory-management.md Co-authored-by: tdykstra <[email protected]> * Remove not-latest-version include from memory-management.md Co-authored-by: tdykstra <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: tdykstra <[email protected]>
1 parent 3688a86 commit c3dd63f

File tree

4 files changed

+108
-19
lines changed

4 files changed

+108
-19
lines changed

aspnetcore/fundamentals/servers/kestrel.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ description: Learn about Kestrel, the cross-platform web server for ASP.NET Core
55
monikerRange: '>= aspnetcore-3.1'
66
ms.author: tdykstra
77
ms.custom: mvc
8-
ms.date: 08/25/2025
8+
ms.date: 12/04/2025
99
uid: fundamentals/servers/kestrel
1010
---
1111
# Kestrel web server in ASP.NET Core
1212

13-
[!INCLUDE[](~/includes/not-latest-version.md)]
13+
[!INCLUDE[](~/includes/not-latest-version-without-not-supported-content.md)]
1414

1515
By [Tom Dykstra](https://github.com/tdykstra), [Chris Ross](https://github.com/Tratcher), and [Stephen Halter](https://twitter.com/halter73)
1616

@@ -33,7 +33,7 @@ Kestrel's features include:
3333
* Building a reverse proxy with [YARP](https://github.com/microsoft/reverse-proxy).
3434
* **Extensibility:** Customize Kestrel through configuration, middleware, and custom transports.
3535
* **Performance diagnostics:** Kestrel provides built-in performance diagnostics features, such as logging and metrics.
36-
* **Memory management:** Kestrel includes features for efficient memory management, such as automatic eviction from memory pool.
36+
* **Memory management:** Kestrel includes features for efficient memory management. For more information, see <xref:fundamentals/servers/kestrel/memory-management>.
3737

3838
## Get started
3939

@@ -43,13 +43,6 @@ ASP.NET Core project templates use Kestrel by default when not hosted with IIS.
4343

4444
For more information on configuring `WebApplication` and `WebApplicationBuilder`, see <xref:fundamentals/minimal-apis>.
4545

46-
## Optional client certificates
47-
48-
For information on apps that must protect a subset of the app with a certificate, see [Optional client certificates](xref:security/authentication/certauth#optional-client-certificates).
49-
50-
51-
[!INCLUDE[](includes/memory-eviction2.md)]
52-
5346
## Additional resources
5447

5548
<a name="endpoint-configuration"></a>

aspnetcore/fundamentals/servers/kestrel/includes/kestrel6.md

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,64 @@
1-
:::moniker range=">= aspnetcore-6.0 <=aspnetcore-9.0"
1+
:::moniker range=">= aspnetcore-8.0 <= aspnetcore-9.0"
2+
3+
Kestrel is a cross-platform [web server for ASP.NET Core](xref:fundamentals/servers/index). Kestrel is the recommended server for ASP.NET Core, and it's configured by default in ASP.NET Core project templates.
4+
5+
Kestrel's features include:
6+
7+
* **Cross-platform:** Kestrel is a cross-platform web server that runs on Windows, Linux, and macOS.
8+
* **High performance:** Kestrel is optimized to handle a large number of concurrent connections efficiently.
9+
* **Lightweight:** Optimized for running in resource-constrained environments, such as containers and edge devices.
10+
* **Security hardened:** Kestrel supports HTTPS and is hardened against web server vulnerabilities.
11+
* **Wide protocol support:** Kestrel supports common web protocols, including:
12+
* HTTP/1.1, [HTTP/2](xref:fundamentals/servers/kestrel/http2) and [HTTP/3](xref:fundamentals/servers/kestrel/http3)
13+
* [WebSockets](xref:fundamentals/websockets)
14+
* **Integration with ASP.NET Core:** Seamless integration with other ASP.NET Core components, such as the middleware pipeline, dependency injection, and configuration system.
15+
* **Flexible workloads**: Kestrel supports many workloads:
16+
* ASP.NET app frameworks such as Minimal APIs, MVC, Razor pages, SignalR, Blazor, and gRPC.
17+
* Building a reverse proxy with [YARP](https://github.com/microsoft/reverse-proxy).
18+
* **Extensibility:** Customize Kestrel through configuration, middleware, and custom transports.
19+
* **Performance diagnostics:** Kestrel provides built-in performance diagnostics features, such as logging and metrics.
20+
21+
## Get started
22+
23+
ASP.NET Core project templates use Kestrel by default when not hosted with IIS. In the following template-generated `Program.cs`, the <xref:Microsoft.AspNetCore.Builder.WebApplication.CreateBuilder%2A?displayProperty=nameWithType> method calls <xref:Microsoft.AspNetCore.Hosting.WebHostBuilderKestrelExtensions.UseKestrel%2A> internally:
24+
25+
:::code language="csharp" source="~/fundamentals/servers/kestrel/samples/6.x/KestrelSample/Program.cs" id="snippet_CreateBuilder" highlight="1":::
26+
27+
For more information on configuring `WebApplication` and `WebApplicationBuilder`, see <xref:fundamentals/minimal-apis>.
28+
29+
## Behavior with debugger attached
30+
31+
The following timeouts and rate limits aren't enforced when a debugger is attached to a Kestrel process:
32+
33+
* <xref:Microsoft.AspNetCore.Server.Kestrel.KestrelServerLimits.KeepAliveTimeout?displayProperty=nameWithType>
34+
* <xref:Microsoft.AspNetCore.Server.Kestrel.KestrelServerLimits.RequestHeadersTimeout?displayProperty=nameWithType>
35+
* <xref:Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerLimits.MinRequestBodyDataRate?displayProperty=nameWithType>
36+
* <xref:Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerLimits.MinResponseDataRate?displayProperty=nameWithType>
37+
* <xref:Microsoft.AspNetCore.Server.Kestrel.Core.Features.IConnectionTimeoutFeature>
38+
* <xref:Microsoft.AspNetCore.Server.Kestrel.Core.Features.IHttpMinRequestBodyDataRateFeature>
39+
* <xref:Microsoft.AspNetCore.Server.Kestrel.Core.Features.IHttpMinResponseDataRateFeature>
40+
41+
## Additional resources
42+
43+
<a name="endpoint-configuration"></a>
44+
* <xref:fundamentals/servers/kestrel/endpoints>
45+
<a name="kestrel-options"></a>
46+
* <xref:fundamentals/servers/kestrel/options>
47+
<a name="http2-support"></a>
48+
* <xref:fundamentals/servers/kestrel/http2>
49+
<a name="when-to-use-kestrel-with-a-reverse-proxy"></a>
50+
* <xref:fundamentals/servers/kestrel/when-to-use-a-reverse-proxy>
51+
<a name="host-filtering"></a>
52+
* <xref:fundamentals/servers/kestrel/host-filtering>
53+
* <xref:test/troubleshoot>
54+
* <xref:security/enforcing-ssl>
55+
* <xref:host-and-deploy/proxy-load-balancer>
56+
* [RFC 9110: HTTP Semantics (Section 7.2: Host and :authority)](https://www.rfc-editor.org/rfc/rfc9110#field.host)
57+
* When using UNIX sockets on Linux, the socket isn't automatically deleted on app shutdown. For more information, see [this GitHub issue](https://github.com/dotnet/aspnetcore/issues/14134).
58+
59+
:::moniker-end
60+
61+
:::moniker range=">= aspnetcore-6.0 < aspnetcore-8.0"
262

363
Kestrel is a cross-platform [web server for ASP.NET Core](xref:fundamentals/servers/index). Kestrel is the web server that's included and enabled by default in ASP.NET Core project templates.
464

@@ -21,10 +81,6 @@ ASP.NET Core project templates use Kestrel by default when not hosted with IIS.
2181

2282
For more information on configuring `WebApplication` and `WebApplicationBuilder`, see <xref:fundamentals/minimal-apis>.
2383

24-
## Optional client certificates
25-
26-
For information on apps that must protect a subset of the app with a certificate, see [Optional client certificates](xref:security/authentication/certauth#optional-client-certificates).
27-
2884
## Behavior with debugger attached
2985

3086
The following timeouts and rate limits aren't enforced when a debugger is attached to a Kestrel process:
@@ -82,10 +138,6 @@ ASP.NET Core project templates use Kestrel by default when not hosted with IIS.
82138

83139
For more information on building the host, see the *Set up a host* and *Default builder settings* sections of <xref:fundamentals/host/generic-host#set-up-a-host>.
84140

85-
## Optional client certificates
86-
87-
For information on apps that must protect a subset of the app with a certificate, see [Optional client certificates](xref:security/authentication/certauth#optional-client-certificates).
88-
89141
## Additional resources
90142

91143
<a name="endpoint-configuration"></a>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: Memory management in Kestrel
3+
author: tdykstra
4+
description: Learn about memory management in Kestrel, including automatic eviction from memory pools and using memory pool metrics.
5+
monikerRange: '>= aspnetcore-10.0'
6+
ms.author: tdykstra
7+
ms.date: 12/04/2025
8+
uid: fundamentals/servers/kestrel/memory-management
9+
---
10+
11+
# Memory management in Kestrel
12+
13+
By [Tom Dykstra](https://github.com/tdykstra)
14+
15+
This article provides guidance for managing memory in Kestrel, including automatic eviction from memory pools and using memory pool metrics.
16+
17+
## Automatic eviction from memory pool
18+
19+
The memory pools used by Kestrel, IIS, and HTTP.sys automatically evict memory blocks when the application is idle or under low load. The feature runs automatically and doesn't need to be enabled or configured manually.
20+
21+
This automatic eviction feature reduces overall memory usage and helps applications stay responsive under varying workloads. In versions of .NET earlier than 10, memory allocated by the pool remained reserved even when not in use.
22+
23+
### Use memory pool metrics
24+
25+
The default memory pool used by the ASP.NET Core server implementations includes metrics, which can be used to monitor and analyze memory usage patterns. The metrics are under the name `"Microsoft.AspNetCore.MemoryPool"`.
26+
27+
For information about metrics and how to use them, see <xref:log-mon/metrics/metrics>.
28+
29+
## Manage memory pools
30+
31+
Besides using memory pools efficiently by evicting unneeded memory blocks, ASP.NET Core provides a built-in [IMemoryPoolFactory](https://source.dot.net/#Microsoft.AspNetCore.Connections.Abstractions/IMemoryPoolFactory.cs) interface and its default implementation, which are available through dependency injection.
32+
33+
The following code example shows a simple background service that uses the built-in memory pool factory implementation to create memory pools. These pools benefit from the automatic eviction feature:
34+
35+
:::code language="csharp" source="~/fundamentals/servers/snippets/10.x/my-background-service.cs":::
36+
37+
To use a custom memory pool factory, make a class that implements `IMemoryPoolFactory` and register it with dependency injection, as the following example does. Memory pools created this way also benefit from the automatic eviction feature:
38+
39+
:::code language="csharp" source="~/fundamentals/servers/snippets/10.x/memory-pool-factory.cs":::
40+
41+
When you're using a memory pool, be aware of the pool's <xref:System.Buffers.MemoryPool`1.MaxBufferSize>.

aspnetcore/toc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,9 @@ items:
11901190
- name: Diagnostics
11911191
displayName: diagnostics
11921192
uid: fundamentals/servers/kestrel/diagnostics
1193+
- name: Memory management
1194+
displayName: memory, pool, kestrel
1195+
uid: fundamentals/servers/kestrel/memory-management
11931196
- name: HTTP/2
11941197
displayName: deploy, publish, server, Kestrel
11951198
uid: fundamentals/servers/kestrel/http2

0 commit comments

Comments
 (0)