Changing the Application Pool on a Web Application the right way

I was working a farm today that had 10 web applications, all with their own application pool.  As we know from , the recommended limit is 10 application pools per WFEs and with the addition of the Web Services App pool, the CA app pool and others, we were over our limit.  Our performance was suffering and we needed a way to consolidate the web application app pools.

Before SharePoint, we'd just open IIS Manager and update the application pool.  But now that's not the correct way: SharePoint doesn't know anything about the change.  Imagine in 2 years from now when you add another WFE - SharePoint would think that we have 10 application pools and would provision them all on the new WFE correctly.  Then you'd have to go in and change them.  What a maintenance nightmare this would be!

To do it correctly, we'll leverage this PowerShell snippet:

$sourceWebAppPool = (Get-SPWebApplication < URL a webapp who’s application pool you want to use>).ApplicationPool

$webApp = Get-SPWebApplication < URL of the web application you want to change>

$webApp.ApplicationPool = $sourceWebAppPool





Here's an example:

In my environment, I have 2 web applications: //VM-SP2010:26927 and //VM-SP2010:4150.  I want :26972 to use the same application pool as :4150.  So my PS is:

$sourceWebAppPool = (Get-SPWebApplication http://VM-SP2010:4150).ApplicationPool

$webApp = Get-SPWebApplication http://VM-SP2010:26927

$webApp.ApplicationPool = $sourceWebAppPool







And After:



Now the change is saved in the config DB and any new WFEs we add will have the correct settings.




Comments (6)

  1. Anonymous says:

    Hi, I have a doubt.

     This change needs to be make in all my servers farm? Or just in one server? Thanks.

  2. Great question:  this is only needed on one server.  The SharePoint timer service will deliver the new config to each server within the farm, as well as every new server that joins the farm.

  3. zakzwijn says:

    Thanks! Together with 'New-SPServiceApplicationPool' this was exactly what I needed.

  4. Sam S. says:

    Same question as Daniel – do you need to do this on all servers in the farm? Or just on one and it will push the change through to the others?

  5. Mary says:

    Thank you!!!

  6. Matt says:

    Sorry for digging up a old post, but does this require a iisreset or would recycle work. Also can this change be made and then on next reset take effect? I would like to make the change but making the change and finding a open window are two challenges that are difficult where I am. I can eventually find one but I could minimize down time by making the change proactivly.

Skip to main content