Tuesday, 22 March 2022

InProcess vs OutOfProcess hosting

 # InProcess vs OutOfProcess hosting

## InProcess Hosting

1. Default hosting model is InProcess in .net core
2. In case of InProcess hosting, CreateDefaultBuilder() method calls UseIIS() method and host the app inside of the IIS worker process (w3wp.exe or iisexpress.exe).
3. From a performance standpoint, InProcess hosting delivers significantly higher request throughput than OutOfProcess hosting
4. In the case of IIS, the process name that executes the app is w3wp and in the case of IIS Express it is iisexpress
5. To get the process name executing the app, use System.Diagnostics.Process.GetCurrentProcess().ProcessName

## OutOfProcess Hosting

1. There are 2 web servers involved here - An internal web server and an external web server.
2. The internal web server is Kestrel and the external web server can be IIS, Nginx or Apache
3. With InProcess hosting, there is only one web server i.e the IIS that hosts the asp.net core application. So, we do not have the performance penalty of proxying requests between internal and external web server.
4. With Out of Process Hosting, using a reverse proxy server is a good choice as it provides an additional layer of configuration and security.
5. It might integrate better with the existing infrastructure. It can also be used for load balancing.
6. So, with a reverse proxy server in place, it receives incoming HTTP requests from the network and forwards them to the Kestrel server for processing. Upon processing the request, the Kestrel server sends the response to the reverse proxy server which then ultimately sends the response to the requested client over the network.
7. With Out of Process Hosting, whether you use a reverse proxy server or not, it is the Kestrel server that hosts the application and process the request.

## What is Kestrel

1. Kestrel is a cross-platform web server for ASP.NET Core. It is supported on all platforms and versions that .NET Core supports.
2. It is included by default as internal server in ASP.NET Core.
3. Kestrel can be used, by itself as an edge server i.e Internet-facing web server that can directly process the incoming HTTP requests from the client.
4. In Kestrel, the process used to host the app is dotnet.exe.
5. When we run a .NET Core application using the .NET Core CLI (Command-Line Interface), the application uses Kestrel as the web server.


No comments:

Post a Comment

Search This Blog

Creating your first "Alexa" Skill

Index What is Alexa What is Alexa Skill? Why is it required when Alexa already equipped with voice assistant? Dev...