You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By [Tom Dykstra](https://github.com/tdykstra), [Chris Ross](https://github.com/Tratcher), and [Stephen Halter](https://twitter.com/halter73)
16
16
@@ -33,7 +33,7 @@ Kestrel's features include:
33
33
* Building a reverse proxy with [YARP](https://github.com/microsoft/reverse-proxy).
34
34
***Extensibility:** Customize Kestrel through configuration, middleware, and custom transports.
35
35
***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>.
37
37
38
38
## Get started
39
39
@@ -43,13 +43,6 @@ ASP.NET Core project templates use Kestrel by default when not hosted with IIS.
43
43
44
44
For more information on configuring `WebApplication` and `WebApplicationBuilder`, see <xref:fundamentals/minimal-apis>.
45
45
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).
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:
*[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).
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.
4
64
@@ -21,10 +81,6 @@ ASP.NET Core project templates use Kestrel by default when not hosted with IIS.
21
81
22
82
For more information on configuring `WebApplication` and `WebApplicationBuilder`, see <xref:fundamentals/minimal-apis>.
23
83
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
-
28
84
## Behavior with debugger attached
29
85
30
86
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.
82
138
83
139
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>.
84
140
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).
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:
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:
0 commit comments