Posted on:
Categories: SharePoint
Description:

Application Architecture:

SharePoint 2010 has two kinds of Application Pools:
  • SP Service Application Pools – Used for SP Service Applications
    • These can be partially managed through the GUI
  • SP Web Application Pools – Used for Web Applications
    • These cannot be managed through the GUI

Microsoft recommends having a maximum of 10 Application Pools per server

Issues:

When an administrator places every single Web App/Service App in a separate Application Pool this causes SharePoint to run inefficiently and consume a large amount of memory. For example, if a server has 20 Application Pools. It will run 20 instances of w3wp.exe, for which each consume about 100mb of ram before loading up a site. Then when sites are loaded on these Application Pools they will consume all available memory as they all believe that they have free reign over the server’s resources. While when Application Pools are consolidated IIS will be able to better manage the available memory.

Solution:

The Solution to this issue is to consolidate the Application Pools so that there is a maximum of 10 per server. To do this, follow my instructions below:

Please do not use IIS to change any Application Pool Settings as SharePoint will freak out during the next psconfig.exe run (SP1 Update, CU Update and Server Addition)

SP Web Application Pools:

Consolidation:

Link : http://gallery.technet.microsoft.com/scriptcenter/Change-SharePoint-Web-64b872d7
PowerShell:

      
#--------------------------------------------------------------------------------------- 
# Name:            Set-WebApplicataionPool.ps1 
# Description:     This script will change SP WebApplication Pools for a Web Application 
#                 
# Usage:        Run the function with the required parameters 
# By:             Ivan Josipovic, Softlanding.ca 
#--------------------------------------------------------------------------------------- 
Function Set-WebApplicataionPool($WebAppURL,$ApplicationPoolName){ 
    $apppool = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.ApplicationPools | where {$_.Name -eq $ApplicationPoolName} 
    if ($apppool -eq $null){ 
        write-host -foreground red "The Application Pool $ApplicationPoolName does not exist!" 
        return 1 
    } 
    $webapp = get-spwebapplication -Identity $WebAppUrl 
    if ($webapp -eq $null){ 
        write-host -foreground red "The Web Application $WebAppUrl does not exist!" 
        return 1 
    } 
    $webapp.Applicationpool = $apppool 
    $webApp.Update() 
    $webApp.ProvisionGlobally() 
    write-host -foreground green "$WebappURL Application Pool has been changed to $ApplicationPoolName" 
    return 0 
} 
 
Set-WebApplicataionPool -WebAppURL "http://sp2010-a:9006" -ApplicationPoolName "SharePoint WebApplications" 

 

 

Deletion:

Once you have consolidated the application pools. Open IIS, go to the Application Pool section. You will notice application pools with 0 associate Applications. Use the following Script to delete them.

Note: This script will only delete SP Web Application Application Pools.

Link: http://gallery.technet.microsoft.com/scriptcenter/Delete-a-SP-WebApplication-9a7d82e4

PowerShell:

    
#------------------------------------------------------------------------------------------------------ 
# Name:            Remove-WebApplicataionPool.ps1 
# Description:     This script will delete SP WebApplication Pools from SP/IIS 
#                 
# Usage:        Run the function with a required parameters 
# By:             Ivan Josipovic, Softlanding.ca 
#------------------------------------------------------------------------------------------------------ 
Function Remove-WebApplicataionPool($ApplicationPoolName){ 
    $apppool = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.ApplicationPools | where {$_.Name -eq $ApplicationPoolName} 
    if ($apppool -eq $null){ 
        write-host -foreground red "The Application Pool $ApplicationPoolName does not exist!" 
        return 1 
    } 
    $apppool.UnProvisionGlobally() 
    write-host -foreground green "$ApplicationPoolName has been deleted" 
    return 0 
} 
 
Remove-WebApplicataionPool -ApplicationPoolName "SharePoint - 8003" 

 

SP Service Application Pools

Consolidation:

To consolidate the Service Application Pools the simplest way is to use the PowerShell

Get-SPServiceApplication - Name "My Service Application" | Set-SPServiceApplication -IisWebServiceApplicationPool "New Application Pool Name"

Deletion:

Use the PowerShell Commands:

Get-SPServiceApplicationPool : to retrieve the names of all the SP Service Application Pools

Remove-SPServiceApplicationPool : to remove unneeded SP Service Application Pools


 

If you have any questions please leave a comment.

Enjoy!