Geeks With Blogs
Jeremy Morgan Ramblings of a Polyglot coder

Intro to Application Pools in IIS

Application Pools in IIS can be somewhat of a mystery. Since they’re created for you automatically many times Administrators don’t give them a second thought. But understanding application pools is crucial to having a good running IIS server.

I cover this and other IIS Administration topics in my IIS Administration Fundamentals course at Pluralsight. Check it out!

What Is an Application Pool?

To understand Application Pools, we must first understand applications, as far as IIS is concerned.

An application is a set of files and folders that deliver content. Any website will have a default application assigned to it, even if it’s just HTML and images. The diagram below shows the web server / web site / application relationship:

What is an Application Pool?

An Application Pool is a container for your applications. It serves to isolate your application from other applications on the server. Each application in an application pool shares a worker process (w3wp.exe). You can have several applications share the same worker process, or have one for each application.

What is an Application Pool?

When setting up Application Pools, you have a few options. Let’s compare a couple patterns.

Multiple Applications in Single Pool

What is an Application Pool?

With this setup every application shares the same pool/process. Some reasons you may want to do this:

  • Simpler Design
  • When making changes you only have to do it once.
  • Caching is improved, code can be shared and cached between applications

Some reasons you may not want to:

  • One crash takes down every application
  • An application with high load will slow the others
  • All applications share the same security profile
  • One applications required setting may break another application.

Each application has its own application pool

What is an Application Pool?

With this setup each application has it’s own unique process.

Some reasons you may want to do this:

  • Isolated operations - if one application fails it doesn’t affect the others.
  • Isolated performance - a higher load application (most likely) will not slow the other applications down.
  • Security can be configured for each application individually.

Some reasons you may not want to do this:

  • Settings cannot be changed globally, must do one by one.
  • Common code caching advantage not present.
  • Could create more overhead than a single pool.

There is no “magic bullet” for this, it will depend on your website and the needs of your organization. It’s definitely something you want to experiment with for best results.

Application Pool Settings

There are some important settings to consider with Application Pools. If you choose the basic settings you don’t get much:

What is an Application Pool?

This only allows you to change your CLR version and Managed pipeline mode. But choose advanced settings and you get far more options:

What is an Application Pool?

Here are some ones I’ve often seen changed:

  • .Net CLR- Although there isn’t a great reason to run a lower version of .Net it does happen. Usually I find myself setting this when the default app pool framework is 2.0.

  • Enable 32 Bit applications - This is a common one for backwards compatibility. For instance the last application I worked on that required this used 32 bit DLLs written in C++, and the application would not function without this setting.

  • Managed Pipeline Mode - This is another one used for backwards compatibility. You may need classic mode for some older ASP applications.

  • Queue Length - this is a throttling setting and it’s pretty rough but useful. What we’re saying here is we can have 1000 requests in the queue, and above that visitors will get a 503 error.

  • Limit - This is another throttling measure that controls the maximum percentage of CPU time you want this application pool to consume.

  • Limit Action specifies what to do when that limit is hit. You can kill the process, throttle it, or do nothing.

  • Limit interval is for fine tuning throttling. After the limit above is hit, this setting controls how many minutes we can stay in that state until recycling. If it’s too long you may have throttling on after it’s no longer needed. Too short and of an interval will just keep it throttling.

  • Identity - This is important because this is the user your application pool is impersonating. Most of the time application pool identity is your best choice, but there are times when you will need a specific user to run a process. In that case you can have this app pool run under that user’s account and it’s given their permissions. Don’t do this unless you absolutely need to. It’s something I’ve seen a lot in the field especially in high security applications.

As I’ve said before, there is no silver bullet for tuning either. It really depends on your organization and how your website is used. A great tune on one website could be bad for another.

How to Create an Application Pool

Creating Application Pools in IIS is easy. You can go into IIS Manager in the Application Pools feature pane, right click and create a new one:

What is an Application Pool?

Or you could create one with PowerShell (my preferred option):

$appPoolName = 'jeremyscoolapp'

if(!(Test-Path IIS:\AppPools\$appPoolName))
{
    $appPool = New-Item $appPoolName
    $appPool | Set-ItemProperty -Name "managedRuntimeVersion" -Value 'v4.0'
}

Set-ItemProperty iis:\Sites\WebsiteName -Name applicationpool -Value $appPoolName

In this script you can see that I define a name for my Application Pool. Then, I test to see if it already exists. If it doesn’t I create a new Application pool. Then I use Set-ItemProperty to change my runtime version to 4.0. You can set any of the application pool settings this way.

To see the options you can change type the following at a PowerShell prompt:

Get-Item IIS:\AppPools\DefaultAppPool  | Select-Object *

Replace DefaultAppPool with the name of your application pool if it’s different.

Conclusion

I hope this has given you a good introduction to application pools in IIS. Because these are created automatically often times administrators don’t give a lot of thought to setting them up. Many websites run just fine with default settings. If you find yourself needing a custom configuration or you have some load issues, you now have a good understand of application pools and where to look to change them.



Are you an IIS Administrator? Do you want to be? Check out my new  IIS Administration Fundamentals course at Pluralsight! - J
Posted on Saturday, July 9, 2016 2:22 AM asp.net , DevOps , IIS , System Administration , Windows , IT , Windows Server | Back to top


Comments on this post: Introduction to Application Pools in IIS

# re: Introduction to Application Pools in IIS
Requesting Gravatar...
nice information...and good explaining

thank you.....
Left by Rakesh on Jul 11, 2016 10:34 AM

# re: Introduction to Application Pools in IIS
Requesting Gravatar...
Good article, thank you. On my hosted (arvixe.com) server, the app pool process (w3wp.exe) shuts down and restarts once every hour at about the same time, even if the application is not active and no pages are being served. Any ideas why this might be happening and how to go about resolving it? Arvixe support is worthless in this regard. TIA, Ungaro.
Left by Ungaro on Jul 11, 2016 1:17 PM

# re: Introduction to Application Pools in IIS
Requesting Gravatar...
I would turn on Logging:

https://technet.microsoft.com/en-us/library/cc732826(v=ws.10).aspx

And capture as much as you can and go through it. If you don't find anything there, application tracing might be able to narrow it down.

I would also take a look at application pool settings. Do you have a high load on this website?
Left by Jeremy Morgan on Jul 11, 2016 9:05 PM

# re: Introduction to Application Pools in IIS
Requesting Gravatar...
It could be that your application pool is recycling every hour.
Check your recycling settings on the application pool.

Jamie.
Left by Jamie Rees on Jul 12, 2016 3:20 AM

# http://www.expertchoice.in/Topic_Details.aspx?TopicName=Resignation%20Letter%20Format
Requesting Gravatar...
good information

thanks
Left by MUKESH KUMAR on Jul 20, 2016 2:49 AM

# re: Introduction to Application Pools in IIS
Requesting Gravatar...
It's nice to learn this process. This will be a relevant process in my project. - Mark Zokle
Left by Daniel Pitt on Aug 02, 2016 3:17 AM

# re: Introduction to Application Pools in IIS
Requesting Gravatar...
Thanks for sharing useful information.It is also a unit of isolation from a security point since the application pool can run with a different identity, and ACL all needed resources exclusively for itself to prevent applications in other application pools from being able to access its resources.check this
https://www.mindstick.com/Articles/1073/application-pool-in-iis-7
Left by marcelethan on Aug 08, 2016 7:04 AM

Your comment:
 (will show your gravatar)


Copyright © Jeremy Morgan | Powered by: GeeksWithBlogs.net