Many times during my work activities, I figure out wrong configurations on web servers. Today, I want to discuss here this topic: web applications cannot be managed and configured like traditional windows applications.
When we think to desktop applications like notepad, we know that each time we run it, O.S. defines a new process (notepad.exe in our example).
Is it true for web application? No, a web application needs a host process to be executed, it means a process that carries on the web application and allows its execution. Starting from IIS6 this process is called w3wp.exe.
Please pay attention, a web application runs on top of an application pool that you define in IIS. An application pool, can be associated to one or more worker process.
A typical mistake is the following: web server administrator defines an application pool and execute many web applications on top of it. I worked with customer who has 20 -30-web applications on top of a single application pool!
This is bad very bad especially for 32 bit process. Let me try to explain why. Every web application needs:
1. Assemblies loaded in memory
2. Memory to calculate the application goal.
In case that you define a single application pool for all web applications, what happens is that all web apps have to load their assemblies and share the same memory. Do you think that this memory is infinite? No, it is not.
In a 32-bit process, by default every application can allocate 2GB of memory and a 32-bit process on a 64 bit machine 4GB. Those values are the maximum ones available by default, but do not except to use all that memory.
Typically, an Out Of Memory exception occurs before that value. It happens due to internal memory fragmentation!
In case that your application are managed one: ASP.NET to be clear, what happened is that Garbage Collector takes care to clean up the memory. If all web applications share the same memory, this one is under pressure.
It means that GC runs a lot of time per second in order to provide clean memory to your app. What is the side effect? In server mode, garbage collector requires to stop all threads activities to clean up the memory (this was improved on .NET Fx 4.5, where the collation does not require to stop all threads). What is the side effect?
- Slow performance of your web application
- High impact on CPU time due to GC’s activity.
Furthermore, if one of your web application crashes, all application running on the same pool will be impacted. Nothing more? There are other things to consider:
Threadpool, the number of thread that single process can define is not infinite. So all web application have to share that number/threads. Same thing for connection pool and so on.
Please do not consider this post in the following way: define necessarily one application pool per web application. This is not the goal, IIS gives you the flexibility to host multiple applications on the same application pool. However, when you decide how many applications have to run on top of the same application pool, take care of above considerations.