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.
I want to try moving to VNext from Asp.Net MVC 3, I used windows service project (http://www.interworks.com/blogs/banderton/2009/10/30/long-running-tasks-aspnet) but this doesn't seem to work on VNext, because it doesn't have proper System.ServiceModel reference and I cant add dll.
Is there a way around? Would you recommend other ways to run long tasks such as big file import/calculations with VNext?
Generally, no - not because of any feature-set in ASP.NET vNext (it's been possible since .NET 1.0) but because of permissions: a process needs to run under a high-privilege security context or be able to impersonate such a user account in order to control Windows Services.
w3wp.exe (the application pool hosting process, and by extension, the application pool and the applications within it) all typically run under a least-privilege user-account (often NT AUTHORITY\NETWORK SERVICE or a custom user account with enough permissions to write to the website's root directory, a database server, and not much else (in recent versions of Windows this is further reduced to the concept of a "service account" which your worker-process and pools run under).
The easiest solution is to create a user-account with the necessary privileges to control services and run your application pool process under this user-account, but I don't recommend this.
Consider, instead, creating a new Windows Service that then controls the other service (or if it's your own service, do it in-proc) that uses some form of IPC to communicate with your ASP.NET application to shut itself down and perform other tasks. You might want to look at named-pipes, for example.
If you need to run ASP.NET in a Windows service, you can do it now using ASP.NET 5. I wrote a detailed post on how to do this here: http://taskmatics.com/blog/host-asp-net-in-a-windows-service/
It's possible to run more that one aplication pool in the same WebApplication on IIS 7 or 7.5? I have one web application on asp.net 4.0 that use EF 4.0 and a large set of Entities. Then the First query Its to slow and when the application pool fails, the users need to login again, but the pool was restarted and the first query Its too slow, this cause any can't login for a time (about the time that the old pool is finished and the new pool It's ready).
If I can use multiple applications pools for the same site, on the same port 8080 for example, thats solve my problem. The only way I found was to create a server farm. However, if I understand, each servers would be a virtual or real machine?
You can have multiple applications and associated pools running under one site directory root. In IIS 7 manager, simply right-click on the folder in question and select "Create Application" in the resulting dialog set the new application pool and the physical path. This will mean that you have to segregate your code into separate projects/modules (web applications or web application projects in vs) but they will all share the same site.
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.
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.