What is Kestrel (vs IIS / Express)

What is the kestrel web server and how does it relate to IIS / IIS Express?

I come from developing applications on IIS Express and hosting them on the IIS web server. The ASP.NET kernel has a dependency on Microsoft.AspNetCore.Server.Kestrel , and my launch has .UseServer("Microsoft.AspNetCore.Server.Kestrel") . But when I launch my site, I still get the IIS Express icon in the system tray. Someone asked me if I use IIS Express or Kestrel, and I did not know what to say!

I have no cross-platform requirements, as I develop on a PC and host in Azure, so I'm confused if I even need Kestrel, but it seems like there is no alternative - even the Simplest samples use Kestrel.

+107
iis asp.net-core
Feb 25 '16 at 21:58
source share
3 answers

What is Kestrel

This is a full-blown web server. You can run the ASP.NET Core application using only Kestrel.

But when I launch my site, I still get the IIS Express icon in the system tray

In your ASP.NET application, probably in the wwwroot directory you will see a web.config file that contains the following:

 <?xml version="1.0" encoding="utf-8"?> <configuration> <system.webServer> <handlers> <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/> </handlers> <httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false" startupTimeLimit="3600"/> </system.webServer> </configuration> 

This is the HttpPlatformHandler. Essentially, this is what all requests to Kestrel do. IIS Express (and IIS, for that matter) will no longer run ASP.NET. Instead, they will act as proxies that simply relay requests and responses from Kestrel. There are still advantages to using IIS, in particular, it gives you security configuration, kernel level caching, etc.

+89
Feb 25 '16 at 22:07
source share

I would like to offer an alternative answer, with some history, so that you can understand why Kestrel comes, even if you use only Windows and IIS.

At the very beginning of ASP.NET development until 2000, obviously Microsoft created two parts to host ASP.NET WebForms applications.

  • Cassini later became the ASP.NET Development Server in Visual Studio. This is a fully managed web server written in C # based on HttpListener . Of course, since it was only for development, many features were never implemented. As Microsoft made Cassini's publicly available source code available, there were third-party developers who forked the code base and added additional features that marked the beginning of the Cassini family.
  • ASP.NET Support in IIS (Revision 1). Since IIS was 4.0 and 5.0 / 5.1 at the time, which had nothing to do with application pools, ASP.NET even had its own workflow ( aspnet_wp.exe ).

Therefore, you use Cassini to develop a web application, and IIS to deploy.

  • The introduction of application pools in IIS 6 required some changes on the ASP.NET side, so aspnet_wp.exe deprecated and replaced by aspnet_isapi.dll . This can be seen as ASP.NET support in IIS version 2. Therefore, ASP.NET applications are hosted in IIS w3wp.exe .

  • Implementing the integrated pipeline in IIS 7 and later required further changes that replaced aspnet_isapi.dll with webengine4.dll . This can be seen as ASP.NET support in IIS version 3. ASP.NET and IIS pipelines are combined.

You can see that ASP.NET has become much more complex and tightly integrated with IIS, so Cassini began to show its age and was gradually replaced by IIS Express (IIS Lightweight User Mode).

Thus, in many cases where people blame IIS for slow work, they must blame ASP.NET for real. IIS itself without ASP.NET is quite fast and stable, while ASP.NET was not designed with sufficient performance in mind (since WebForms focuses quite a bit on performance and RAD).

Then, in November 2014, it was announced that ASP.NET 5 (later renamed ASP.NET Core) became a cross-platform technology. Obviously, Microsoft needed a new design to support Windows, macOS and Linux, where you should consider all the main web servers, nginx / Apache (or other web servers), except for IIS.

I think that many will agree that Microsoft learned a lot from NodeJS, and then designed and developed Kestrel (originally based on libuv but may soon switch to other technologies). Initially, it was a lightweight web server, such as Cassini, but later additional functions are added (as in another answer, there are much more functions that can be considered as a full-fledged web server). Although it is fully manageable (there are some native dependencies), it is no longer a toy web server such as Cassini.

Then why can't you just use Kestrel? Why are IIS Express and potentially IIS, nginx or Apache still needed? This is primarily the result of modern Internet practice. Most websites use reverse proxies to receive requests from your web browsers, and then redirect them to application servers in the background.

  • IIS Express / IIS / nginx / Apache are reverse proxies
  • Kestrel / NodeJS / Tomcat etc. Are application servers

Another answer already showed a link to Microsoft documentation, so you can take a look.

Microsoft originally developed the HttpPlatformHandler to make IIS a good reverse proxy server for Java / Python, etc., so it planned to use it for ASP.NET Core. Problems started to appear during development, so Microsoft later made the ASP.NET Core module specifically for ASP.NET Core. ASP.NET support in IIS version 4.

Starting with ASP.NET Core 2.2, ASP.NET Core for IIS (version 2) can host the .NET Core environment inside the IIS workflow ( w3wp.exe ), very similar to ASP.NET 2.x / 4.x. This mode is called "IIS in-process hosting" . This can be seen as ASP.NET support in IIS version 5.

Well, for quite some time, but I hope that I collect all the necessary pieces and you enjoy reading.

+90
Oct 22 '17 at 20:08 on
source share

From the MS documentation: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?tabs=aspnetcore2x

Kestrel is a cross-platform web server for ASP.NET Core, based on libuv, a cross-platform asynchronous I / O library. Kestrel is a web server that is included by default in ASP.NET Core project templates.

You can use Kestrel separately or with a reverse proxy server such as IIS, Nginx or Apache. The reverse proxy server receives HTTP requests from the Internet and redirects them to Kestrel after some preliminary processing.




UPDATE: .net core 2.1, instead of libuv Kestrel uses managed sockets

From the asp.net core 2.1 documentation at: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore-2.1#transport-configuration

With the release of ASP.NET Core 2.1, the default Kestrel transport is no longer based on Libuv, but on managed sockets.

+7
13 Sep '17 at 9:52 on
source share



All Articles