NET. 6 on Docker Container and Application Pool Recycle - asp.net

I am developing an application on .NET6 using Microsoft Blazor. I have containerized this application to be able to deploy with more flexibility and to avoid Azure Web Apps problems.
Azure Web Apps is an Azure service which can host web applications like .NET 6 applications but while running on this service, several things can happen:
Server Swap, service is changing the underlying infrastructure, this can be avoided by using the ARR AFFINITY switch form the Azure Portal
Server Upgrades, framework or storage upgrades causes application to be restarted at any time
Application Pool recycle with periodic recycle intervals
So when we have an application which has a stateful mechanism such as a thread pool, all the treads will be cleared after the application is restarted.
Here is an example of a random restart:
One cool way that I found to overcome these issues, is by using Docker Containers which they can implement the .NET 6.
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
I have already tested this and my application is running without any problem or restart for a week by now while in Azure I had at least two restarts inside a week.
My concern now is more about Application Pool recycle, I was familiar in the past with IIS but now I am sure how this is handled in docker container, if there is an IIS behind with settings and if there is, how I can check the 'DisableOverlappedRecycle', 'DisableRecyclingConfigChange' and 'Idle Time-out' options.
Any ideas?

Looking inside the running Docker container which build by the Dockerfile to understand the deployment, found the project files but also the Web.config file.
That means that an IIS is running, which can accept several settings there like DisableOverlappedRecycle', 'DisableRecyclingConfigChange' and 'Idle Time-out' options.

Related

About IIS APPPOOL

I have to debug a WCF hosted in local IIS. Each time I have to attach two processes "w3wp.exe".
One ID is 7624, the other is 8372.
Users: one is "IIS APPPOOL\ASP.NET V4.0 Integrated[administrator]
the other one is "IIS APOOL DefaultAppPool[administrator]
Questions:
What they are? (google search but bo clue)
Can I just attach one process rather all?
Thanks
Updated:
See IIS image:
Just check in your IIS Management Console the Application Pool in which your site resides, then attach to the proper one. Probably, as you're using WCF, you're running under .NET 4, so under the first process you linked.
Application pool is the set of apps that run under same worker process.
Important thing in practice is that one app pool can serve only applications with same version of .NET (version of .NET CLR - to be precise). It is also good to remember that applications from the same app pool will "share" recycling of worker process.
So, you should look up at the IIS in which app pool your service is running and debug only process associated with this app pool.
They are Application Pool Identities. This is the newer (and securer) way of assigning priveleges to websites. Essentially a site runs on its own application pool, so you assign rights to files based on that pool.
See: http://www.iis.net/learn/manage/configuring-security/application-pool-identities

IIS 6.1 Server 2003 Web Apps Don't Startup on Reboot Sometimes

Occasionally when I reboot one of the servers at a client site the Web Apps running in IIS do not automatically start backup when the server is done rebooting. The IIS service starts up just fine, its set to Auto Start and there are no errors in the event log. Just none of the Web Apps are running, I have to click each one and click start. This only happens occasionally, as they usually start but its completely baffling.
Any thoughts? Its a mix of Classic ASP and ASP.NET applications. There are a total of 4 application pools running between around 8 web applications.
I have seen this happen when apps rely on a resource that is not yet available to the server, such as a network share.
Some people combat this problem by writing a Windows Service who's job is to check for such conditions and start the application.

Confusing terminologies pertaining to Application Pool, Worker Process and Application Domain

Edit 1
I am confused with the statement below, taken from What ASP.NET Programmers Should Know About Application Domains :
You’ve created two ASP.NET
applications on the same server, and
have not done any special
configuration. What is happening?
A single ASP.NET worker process will
host both of the ASP.NET applications.
On Windows XP and Windows 2000 this
process is named aspnet_wp.exe, and
the process runs under the security
context of the local ASPNET account.
On Windows 2003 the worker process has
the name w3wp.exe and runs under the
NETWORK SERVICE account by default.
He said that there is one worker process spawns 2 application domains--one application domain for each asp.net application.
But when I see the running processes as follows,
Image 1
Image 2
w3wp.exe is said as IIS Worker Process rather than application pool or application domain.
Questions:
Is application domain equal to application pool?
The confusing thing is in image 1. Why does Host Process Windows Service svchost.exe spawns 2 IIS Worker Process w3wp.exe? In my understanding, a process can only contain application domains, not other processes.
Application domain aka AppDomain (its class representation) is an encapsulated environment inside a .NET runtime where assemblies are loaded and running.
Usually there is one AppDomain/Application domain per managed process but can be more. Here the article refers to 2 AppDomains inside the same w3wp3.exe process.
You can see number of AppDomains loaded in any process using perfmon.exe
To answer your question, usually one AppDomain is created per one AppPool. But it is possible to load extra AppDomains manually in the AppPool by the application - but that would be very uncommon.
Update
I think you are using Process Explorer of the Sysinternals. Ignore the way it shows the tree structure in there, it only illustrates which process has spawned other processes. In fact it shows most processes underneath explorer since explorer has been used to load it.
Also SVCHOST.exe is an unmanaged executable and although it can host CLR and load AppDomains, it normally does not do that.

What is an IIS application pool?

What exactly is an application pool? What is its purpose?
Application pools allow you to isolate your applications from one another, even if they are running on the same server. This way, if there is an error in one app, it won't take down other applications.
Additionally, applications pools allow you to separate different apps which require different levels of security.
Here's a good resource: IIS and ASP.NET: The Application Pool
I second the top voted answer, but feel like adding little more details here if anyone finds it useful.
short version:
IIS runs any website you configure in a process named w3wp.exe. IIS
Application pool is feature in IIS which allows each website or a part
of it to run under a corresponding w3wp.exe process. So you can run
100 websites all in a single w3wp.exe or 100 different w3wp.exe. E.g.
run 3 websites in same application pool(same w3wp.exe) to save memory
usage. ,run 2 different websites in two different application pools so
that each can run under separate user account(called application pool
identity). run a website in one application pool and a subsite
'website/app' under a different application pool.
Longer version:
Every website or a part of the website,you can run under an application pool.You can control some basic settings of the website using an application pool.
You would like the website to run under a different w3wp.exe process.Then create a new application pool and assign that to the website.
You would like to run the website and all it's code under a different user account(e.g under Admin privileges),you can run do that by changing Application Pool Identity.
You would like to run a particular application under .net framework 4.0 or 2.0.
You would like to make sure the website in 32 bit mode or have a scheduled recycle of the w3wp.exe process etc.All such things are controlled from iis application pool.
Basically, an application pool is a way to create compartments in a web server through process boundaries, and route sets of URLs to each of these compartments. See more info here: http://technet.microsoft.com/en-us/library/cc735247(WS.10).aspx
An application pool is a group of one or more URLs that are served by a worker process or set of worker processes. Any Web directory or virtual directory can be assigned to an application pool.
Every application within an application pool shares the same worker process.
Assume scenario where swimmers swim in swimming pool in the areas reserved for them.what happens if swimmers swim other than the areas reserved for them,the whole thing would become mess.similarly iis uses application pools to seperate one process from another.
IIS-Internet information Service is a web server used to host one or more web application .
Lets take any example here say Microsoft is maintaining web server and we are running our website abc.com (news content based)on this IIS.
Since, Microsoft is a big shot company it might take or also ready to host another website say xyz.com(ecommerce based).
Now web server is hosting i.e providing memory to run both websites on its single web server.Thus , here application pools come into picture .
abc.com has its own rules, business logic , data etc and same applies to xyz.com.
IIS provides two application pools (path) to run two websites in their own world (data) smoothly in a single webserver without affecting each ones matter (security, scalability).This is application pool in IIS.
So you can have any number of application pool depending upon on servers capacity
An application pool is a group of urls served by worker processors or set of worker processors.
There can exist any number of application pools.
In IIS it is possible to create more than one application pool.
An application in different application pool runs in different worker processors.
Advantage: If an error occurred in one application pool will not effect the applications running in another application pool.
An Application pool is a collection of applications which uses the same worker process of IIS (w3wp.exe). Primary concern of using Application pool is to isolate two different applications with different security concerns and also to avoid crashing of applications due to worker process death.
An application pool is a group of one or more URLs that are served by a worker process or set of worker processes. Application pools are used to separate sets of IIS worker processes that share the same configuration and application boundaries. Application pools are used to isolate our web application for better security, reliability, availability and performance, and they keep running without impacting each other.
Application pools are used to separate sets of IIS worker processes that share the same configuration and application boundaries.
Application pools used to isolate our web application for better security, reliability, and availability and performance and keep running without impacting each other . The worker process serves as the process boundary that separates each application pool so that when one worker process or application is having an issue or recycles, other applications or worker processes are not affected. One Application Pool can have multiple worker process Also.
Or we can simply say that, An application pool is a group of one or more URLs that are served by a worker process or set of worker processes. Any Web directory or virtual directory can be assigned to an application pool. So that one website cannot be affected by other, if u used separated application pool.
Source : Interviewwiz
An application pool is like a pond, if I create 2 application pools, first application pool has 100 fishes and another application pool has 200 fishes, here fish is like an application in application pool.
They are managed by worker processes. Best advantage is: if pond number-1 has bad water and cases all fish are effected then there is security of fish in pond number-2. Like this if any application pool is affected by any problem but there is not any effect of this problem in application pool 2 so security improves, and another benefit is that is you provide all the necessary authentication and rights to all applications in a single application pool.
An application pool is a group of one or more URLs that are served by a worker process or set of worker processes. Application pools are used to separate sets of IIS worker processes that share the same configuration and application boundaries.
Application pools are used to separate set of IIS worker processes that share the same configuration.
Application pools enable us to isolate our web application for better security, reliability, and availability
The application Pools element contains configuration settings for all application pools running on your IIS. An application pool defines a group of one or more worker processes, configured with common settings that serve requests to one or more applications that are assigned to that application pool.
Because application pools allow a set of Web applications to share one or more similarly configured worker processes, they provide a convenient way to isolate a set of Web applications from other Web applications on the server computer.
Process boundaries separate each worker process; therefore, application problems in one application pool do not affect Web sites or applications in other application pools. Application pools significantly increase both the reliability and manageability of your Web infrastructure.
application pool provides isolation for your application. and increase the availability of your application because each pool run in its own process so an error in one app won't cause other application pool. And we have shared pool that hosts several web applications running under it and dedicated pool that has single application running on it.

IIS6 | Application Pools | ASP.NET Framework

In IIS6 it's possible to have more than one ASP.NET application running in the same application pool. This is fine, except that there is nothing in IIS6 that prevents you from running multiple .NET versions in the same pool.
When you create application pools in IIS7 you must explicitly state was .NET version will be running in that pool. Running multiple .NET versions in IIS7, in the same application, is impossible.
How can I enforce such rules on my IIS6 server in order to prevent my deployment team from creating such problems?
What I do:
Step 1. Create the following application pools:
.NET 1.1 Apps
.NET 2.0 Apps
Step 2. Disable the "Default App Pool"
Now, any time a new application is configured in IIS, it will not work right away because the default app pool is disabled. This forces the person configuring the application to select an app pool that is appropriate for the .NET framework version of the app.
We tend to use one application pool per site, so that each application is isolated in its own process space. Application pool recycles will only affect a single application, and each worker process ends up with its own 4gb memory space. Badly programmed applications have no chance of affecting other applications, resulting in a highly isolated deployment model.
We've also standardized on x64 OS builds running 32bit application pools. While there is overhead using this technique since each application ppol contains a separate copy of the .Net framework, we feel that the added granularity of the application space adds stability to our deployments. You also get the ability to run each application as it's own domain identity, allowing for further memory space isolation and eliminating any need for identity impersonate in web configs.
With IIS 7, you have the ability to run each application pool as either 32 bit or 64 bit, so you can run large memory applications in 64 bit application pools. IIS 7 application pool security is also much more simplified.
I don't think you can. What I do is name my app pools in IIS 6 so that they show what .Net version they host. That way it's easy to pick the correct app pool when creating a new application.
If I remember correctly, you can also setup application pools in IIS6 (Windows 2003). Create one application pool per framework version in use.
I am not aware of any possibility to enforce the version of the .NET framework being used by an application. If you have setup an application pool to use .NET 1.1 and you have a .NET 2.0 application running in that application pool, you will get an exception in the application (yellow screen of death), since it will not find some referenced assemblies and classes.

Resources