What is Kestrel, and how does its role in ASP.NET Core hosting differ from a traditional web server like IIS?
Short answer
Kestrel is the default, cross-platform, high-performance web server built directly into ASP.NET Core, responsible for handling raw HTTP connections and requests -- unlike IIS (a full-featured Windows web server providing process management, SSL termination, static file serving…
Advertisement
AModel answer
Kestrel is the default, cross-platform, high-performance web server built directly into ASP.NET Core, responsible for handling raw HTTP connections and requests -- unlike IIS (a full-featured Windows web server providing process management, SSL termination, static file serving, and more historically as the primary way to host .NET applications), Kestrel is deliberately lightweight and focused purely on serving the application, commonly used either standalone (directly exposed) or, in production, placed behind a reverse proxy for additional capabilities.
// Program.cs -- Kestrel is used automatically via WebApplication.CreateBuilder
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/", () => "Hello from Kestrel");
app.Run();
// Kestrel listens directly on the configured port, e.g. http://localhost:5000Real-world example
A containerized microservice runs Kestrel directly as its web server inside a Docker container, with no IIS involved at all, since the container orchestration platform (Kubernetes) and its ingress controller handle routing and load balancing instead.
Likely follow-ups
- When would you run Kestrel directly without any reverse proxy in front of it?
- What capabilities does IIS or a reverse proxy add that Kestrel alone doesn't provide?
Related topics