How many web applications per application pool

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! Surprised smile
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. Winking smile


Comments (7)
  1. Shahrooz jefri says:

    Thanks.i defined one  application pool for all application


  2. Nazareno says:

    I defined one  application pool for all applications too and somtimes a have really long service time response.

    Do you have any guidelines about how may application can be managed by the same appPool (obviously making some semplification about the memory usage of every service)?

  3. There is not a deterministic way to find out how many applications have to run on the same app pool. You could check some performance counter value, like virtual memory in use, number of requests in execution and so on. As general suggestion: do some tests to understand the best tuning 🙂

  4. Davor says:

    Thanks for this. It helps me a lot… but what if i use 10 applications that use same (user) connection string to database. and there is somewhere on some application part that do not close connection (forgot to add) or do not close datareader? this could affect other applications even if they are not in same application pool? should i create new user to database for every application?

  5. Connection pool is an entity available at process/application level. In case that an application leaks DB connections, this mistake affect only its process/application.



  6. ajay rathi says:

    Thanks for the post. it has good information. Although It is old post but i would like to make one more point.

    Every application pool runs under one user identity and in this case if we would run more web applications under one applications pool and if that user will be locked (due to any reason) then all applications would be stopped.

    So best way is to make one application pool per web application.

  7. kamal says:

    Is possible to configure multiple application pool to one application ?

Comments are closed.

Skip to main content