Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 46 additions & 5 deletions aspnetcore/fundamentals/servers/kestrel.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: Learn about Kestrel, the cross-platform web server for ASP.NET Core
monikerRange: '>= aspnetcore-3.1'
ms.author: tdykstra
ms.custom: mvc
ms.date: 08/25/2025
ms.date: 12/04/2025
uid: fundamentals/servers/kestrel
---
# Kestrel web server in ASP.NET Core
Expand Down Expand Up @@ -33,7 +33,7 @@ Kestrel's features include:
* Building a reverse proxy with [YARP](https://github.com/microsoft/reverse-proxy).
* **Extensibility:** Customize Kestrel through configuration, middleware, and custom transports.
* **Performance diagnostics:** Kestrel provides built-in performance diagnostics features, such as logging and metrics.
* **Memory management:** Kestrel includes features for efficient memory management, such as automatic eviction from memory pool.
* **Memory management:** Kestrel includes features for efficient memory management. For more information, see <xref:fundamentals/servers/kestrel/memory-management>.

## Get started

Expand All @@ -43,12 +43,53 @@ ASP.NET Core project templates use Kestrel by default when not hosted with IIS.

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

## Optional client certificates
## Additional resources

<a name="endpoint-configuration"></a>
* <xref:fundamentals/servers/kestrel/endpoints>
<a name="kestrel-options"></a>
* <xref:fundamentals/servers/kestrel/options>
<a name="http2-support"></a>
* <xref:fundamentals/servers/kestrel/http2>
<a name="when-to-use-kestrel-with-a-reverse-proxy"></a>
* <xref:fundamentals/servers/kestrel/when-to-use-a-reverse-proxy>
<a name="host-filtering"></a>
* <xref:fundamentals/servers/kestrel/host-filtering>
* <xref:test/troubleshoot>
* <xref:security/enforcing-ssl>
* <xref:host-and-deploy/proxy-load-balancer>
* [RFC 9110: HTTP Semantics (Section 7.2: Host and :authority)](https://www.rfc-editor.org/rfc/rfc9110#field.host)
* 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).

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).
:::moniker-end

:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"

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.

Kestrel's features include:

[!INCLUDE[](includes/memory-eviction2.md)]
* **Cross-platform:** Kestrel is a cross-platform web server that runs on Windows, Linux, and macOS.
* **High performance:** Kestrel is optimized to handle a large number of concurrent connections efficiently.
* **Lightweight:** Optimized for running in resource-constrained environments, such as containers and edge devices.
* **Security hardened:** Kestrel supports HTTPS and is hardened against web server vulnerabilities.
* **Wide protocol support:** Kestrel supports common web protocols, including:
* HTTP/1.1, [HTTP/2](xref:fundamentals/servers/kestrel/http2) and [HTTP/3](xref:fundamentals/servers/kestrel/http3)
* [WebSockets](xref:fundamentals/websockets)
* **Integration with ASP.NET Core:** Seamless integration with other ASP.NET Core components, such as the middleware pipeline, dependency injection, and configuration system.
* **Flexible workloads**: Kestrel supports many workloads:
* ASP.NET app frameworks such as Minimal APIs, MVC, Razor pages, SignalR, Blazor, and gRPC.
* Building a reverse proxy with [YARP](https://github.com/microsoft/reverse-proxy).
* **Extensibility:** Customize Kestrel through configuration, middleware, and custom transports.
* **Performance diagnostics:** Kestrel provides built-in performance diagnostics features, such as logging and metrics.

## Get started

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:

:::code language="csharp" source="~/fundamentals/servers/kestrel/samples/6.x/KestrelSample/Program.cs" id="snippet_CreateBuilder" highlight="1":::

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

## Additional resources

Expand Down
8 changes: 0 additions & 8 deletions aspnetcore/fundamentals/servers/kestrel/includes/kestrel6.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ ASP.NET Core project templates use Kestrel by default when not hosted with IIS.

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

## Optional client certificates

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).

## Behavior with debugger attached

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

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>.

## Optional client certificates

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).

## Additional resources

<a name="endpoint-configuration"></a>
Expand Down
43 changes: 43 additions & 0 deletions aspnetcore/fundamentals/servers/kestrel/memory-management.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
title: Memory management in Kestrel
author: tdykstra
description: Learn about memory management in Kestrel, including automatic eviction from memory pools and using memory pool metrics.
monikerRange: '>= aspnetcore-10.0'
ms.author: tdykstra
ms.date: 12/04/2025
uid: fundamentals/servers/kestrel/memory-management
---

# Memory management in Kestrel

[!INCLUDE[](~/includes/not-latest-version.md)]

By [Tom Dykstra](https://github.com/tdykstra)

This article provides guidance for managing memory in Kestrel, including automatic eviction from memory pools and using memory pool metrics.

## Automatic eviction from memory pool

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.

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.

### Use memory pool metrics

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"`.

For information about metrics and how to use them, see <xref:log-mon/metrics/metrics>.

## Manage memory pools

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.

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:

:::code language="csharp" source="~/fundamentals/servers/snippets/10.x/my-background-service.cs":::

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:

:::code language="csharp" source="~/fundamentals/servers/snippets/10.x/memory-pool-factory.cs":::

When you're using a memory pool, be aware of the pool's <xref:System.Buffers.MemoryPool`1.MaxBufferSize>.
3 changes: 3 additions & 0 deletions aspnetcore/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,9 @@ items:
- name: Diagnostics
displayName: diagnostics
uid: fundamentals/servers/kestrel/diagnostics
- name: Memory management
displayName: memory, pool, kestrel
uid: fundamentals/servers/kestrel/memory-management
- name: HTTP/2
displayName: deploy, publish, server, Kestrel
uid: fundamentals/servers/kestrel/http2
Expand Down
Loading