次の方法で共有


Tips on Performance Enhancements while Working with Windows 7 as a SharePoint development platform

Recently I have installed SharePoint Server 2010 on Windows 7 Enterprise edition in my laptop. It is really really cool, you really love it because while working we won’t feel that we are working in server box like in Windows 2003 / 2008 server , because of the fancy look and performance. I love it !, if anyone want to know the exact steps on how to setup SharePoint 2010 on Windows 7 please follow this MSDN article

There are people like me who travel most often , use laptop to show demo (on SharePoint) to customers. Though there are so many other options to setup SharePoint development environment like install Windows 2008 Server as a dual boot, or on top of Windows 2008 Server setup VMs in Hyper-V, Create a bootable VHD ( but I am encrypting my HDD using the bit locker so that it won’t be an option for me), setup a VM in virtualbox etc, but I stick with my Windows 7 Enterprise edition and I am happy, why because…please read the details below.

I have installed so many applications like office 2010, my work related CRM tools, and other third party tools in my laptop. Apart from that I have installed SharePoint Server 2010 in standalone mode (Standalone installation will install SQL Server 2008 Express edition automatically – Instance name would be “machinename\SharePoint” ) My laptop’s (Lenovo W500) base configuration is 8 GB RAM , and Intel® Core ™2 Duo CPU P9600 2.66GHz , it is pretty powerful one. Minimum recommended RAM for SharePoint development machine is 4 GB and can give up to 8 GB, but from my experience what I would say that if your development box is not dedicated to SharePoint, say like a laptop for personal / official use as well then that case use at least 6 GB.

What I have seen that whenever I use most of my applications running with SharePoint, memory usage always going up to 4 GB (in between 3.90 and 4.2). Also, most often after my use I always switch off my laptop and will boot it whenever I needed, at that time I have seen machine is taking little bit more time to be in the ready to use state. Reason for the mentioned behavior was because once we install SharePoint there are some (more than 6) services which will be running in behind + SQL service instance service. What I saw that once I stop all those services system will perform well. So, what I thought that use SharePoint only when I required otherwise make my environment as a pure Windows 7 installation for an ordinary user (means not for a SP developer). Because there are so many situations where I won’t touch SharePoint, like writing emails to customers’ , peers, managers, watching movies etc. But it will be little cumbersome once we try to stop all the services one by one and later start all those. There we will get the help of “PowerShell”, I have used 2 PowerShell scripts , one for starting all the services and another one for stopping.

Here is a screen shot of my task manager’s performance monitor that I have taken whenever I use SharePoint and all other applications running in my environment.

              image

The PowerShell script below will just stop all the services one by one and thus we can reclaim memory taken by SharePoint related services. I have attached both the scripts with this post to download or you can just copy and paste the below script into a notepad file and rename it as .PS1 file, after that you can run it from the PowerShell console.

 # Notes
  
 set-alias stsadm "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN\stsadm.exe"
  
 Function Shutdown-process($s)
 {
     Write-Host Stopping $s
     if(Get-Process $s -ea Silentlycontinue){Stop-Process -processname $s -force} else{Write-Host $s not running}
 }
  
 Function Shutdown-service([string]$s)
 {
     Write-Host Stopping $s
     get-service $s | Where{$_.Status -eq "Running"} | stop-service -force
 }
  
 Function stop-spservice-type([string]$s)
 {
     Write-Host Stopping $s
     stsadm -o provisionservice -action start -servicetype $s 
     Write-Host
 }
  
 Function stop-spservice-typename([string]$s,[string]$n)
 {
     Write-Host Stopping $n
     stsadm -o provisionservice -action start -servicetype $s -servicename $n
     Write-Host
 }
  
 Function set-sqlmemory
 {
     get-pssnapin | Where{$_.Name -eq "sqlserverprovidersnapin100"} | remove-pssnapin
     get-pssnapin | Where{$_.Name -eq "sqlservercmdletsnapin100"} | remove-pssnapin
     
     add-pssnapin sqlserverprovidersnapin100
     add-pssnapin sqlservercmdletsnapin100
  
     Write-Host Setting SQL Server max and min memory...    
     set-location sqlserver:\sql\localhost\sharepoint  
     invoke-sqlcmd "exec sp_configure 'show advanced options', 1;"
     invoke-sqlcmd "GO"
     invoke-sqlcmd "RECONFIGURE"
     invoke-sqlcmd "exec sp_configure 'max server memory',450;"
     invoke-sqlcmd "RECONFIGURE WITH OVERRIDE"
     invoke-sqlcmd "exec sp_configure 'min server memory',450;"
     invoke-sqlcmd "RECONFIGURE WITH OVERRIDE"
 }
  
 Write-Host Commencing SharePoint 2010 Shutdown... -foregroundcolor Red
 Write-Host
  
 Write-Host Setting SharePoint logging level to none...
 stsadm -o setlogginglevel -tracelevel none -windowslogginglevel none
  
 # set-sqlmemory  --- needs a fix --- added ---- set-location sqlserver:\sql\localhost\sharepoint  
  
 Shutdown-service WebAnalyticsService
  
 Shutdown-service OSearch14
  
 Shutdown-service SPUserCodeV4
  
 Shutdown-service SPSearch4
  
 Shutdown-service SPTimerV4
  
 Shutdown-service SPTraceV4
  
 Shutdown-service FontCache3.0.0.0
  
 stop-spservice-type ExcelServerWebService
  
 stop-spservice-type WordService
  
 Shutdown-service 'MSSQL$SharePoint'
  
 # Do not shutdown process unless you know path to restart
 # Shutdown-process OSPPSVC 
  
 # Do not shutdown process unless you know path to restart
 #Shutdown-process sqlwriter
  
 # Do not shutdown process unless you know path to restart
 # Shutdown-process SYNCPROC
  
 iisreset /stop 
 # noforce or restart
  
 Write-Host
 Write-Host SharePoint 2010 Shutdown Complete. -foregroundcolor Red
 Write-Host
 Write-Host
 Write-Host Output Web site status. -foregroundcolor Green
 Write-Host
 import-module WebAdministration
 Get-Website

After running the above script my machine was able to reclaim the memory.

             image

Below PowerShell Script will start all the services and you will get your SharePoint environment ready.

 # Notes
  
 set-alias stsadm "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN\stsadm.exe"
  
 Function Start-process($s)
 {
     Write-Host Starting $s
     #if(Get-Process $s -ea Silentlycontinue){Start-Process -processname $s -wait} else {Write-Host $s not running}
     Start-Process -processname $s -wait
 }
  
 Function Start-service([string]$s)
 {
     Write-Host Starting $s
     #get-service $s | Where{$_.Status -eq "stopped"} | start-service
     get-service $s | where {$_.Status -eq "Stopped"} | restart-service -force
    
 }
  
 Function Start-spservice-type([string]$s)
 {
     Write-Host Starting $s
     stsadm -o provisionservice -action start -servicetype $s 
     Write-Host
 }
  
 Function Start-spservice-typename([string]$s,[string]$n)
 {
     Write-Host Starting $n
     stsadm -o provisionservice -action start -servicetype $s -servicename $n
     Write-Host
 }
  
 Function set-sqlmemory
 {
     get-pssnapin | Where{$_.Name -eq "sqlserverprovidersnapin100"} | remove-pssnapin
     get-pssnapin | Where{$_.Name -eq "sqlservercmdletsnapin100"} | remove-pssnapin
     
     add-pssnapin sqlserverprovidersnapin100
     add-pssnapin sqlservercmdletsnapin100
  
     Write-Host Setting SQL Server max and min memory...    
     set-location sqlserver:\sql\localhost\sharepoint  
     invoke-sqlcmd "exec sp_configure 'show advanced options', 1;"
     invoke-sqlcmd "GO"
     invoke-sqlcmd "RECONFIGURE"
     invoke-sqlcmd "exec sp_configure 'max server memory',450;"
     invoke-sqlcmd "RECONFIGURE WITH OVERRIDE"
     invoke-sqlcmd "exec sp_configure 'min server memory',450;"
     invoke-sqlcmd "RECONFIGURE WITH OVERRIDE"
 }
  
 Write-Host Starting SharePoint 2010 Server... -foregroundcolor Green
 Write-Host
  
 Start-service 'MSSQL$SharePoint'
  
 Start-service SPSearch4
  
 Start-service SPTimerV4
  
 Start-service SPTraceV4
  
 Start-service FontCache3.0.0.0
  
 #Path is required to start process
 #Start-process OSPPSVC
  
 #Start-process sqlwriter
  
 #Start-process SYNCPROC
  
 Start-spservice-type ExcelServerWebService
  
 Start-spservice-type WordService
  
 Start-service WebAnalyticsService
  
 Start-service OSearch14
  
 Start-service SPUserCodeV4
  
 iisreset /restart 
 # noforce or restart
  
 Write-Host Setting SharePoint logging level to Error...
 stsadm -o setlogginglevel -tracelevel medium -windowslogginglevel error
 #Configure at https://technet.microsoft.com/en-us/library/cc288592.aspx
  
 set-sqlmemory 
 # -- added --- set-location sqlserver:\sql\localhost\sharepoint  
  
 Write-Host
 Write-Host SharePoint 2010 is running. -foregroundcolor Green
 Write-Host
 Write-Host
 Write-Host Output Web site status. -foregroundcolor Green
 Write-Host
 import-module WebAdministration
 Get-Website

NOTE: If you are planning to use these scripts make sure that you configure all those services start as “Manual”. Otherwise once you restart the machine and if all the services are configured as “Auto” or “Auto (delayed)” [however the Auto (delayed) method will give some performance over “Auto”] all service will get started again. Also, don’t practice or implement this in your production environments. All these tips are just for your development machine to make you more comfortable.

IIS – “Ping Maximum Response Time” setting:-

One another tip that I want to mention here is about the “Ping Maximum Response Time” of your Application pool settings. By default its value would be 90 seconds. If you set that value it may end up with an issue while you debug your applications. There might be some situations where you will spend more time in investigating the values of specific variables , debugging line by line etc, in that case you may get an error with message says that “Web site worker process has been terminated by IIS”

When you are debugging, IIS will not service any other requests until you are done stepping through your code. That includes the "ping" request that IIS sends to itself. Since IIS doesn't hear back from itself, it decides to shut itself down, which promptly terminates your debugging.

        image

The solution is to increase the Ping Maximum Response Time in the application pool settings from its default value of 90 seconds. Set it to something high enough that will give you enough time to debug your code (like maybe 300 seconds).If you want to know the exact steps please follow this MSDN article.

Hope these inform will be helpful. Please find the attached PowerShell script for testing.

Start Stop Services_PS.zip

Comments

  • Anonymous
    November 03, 2010
    Hi, Youmight even have a look at this codeplex utility ... VEry very helpful ... sharepointserviceman.codeplex.com Varun

  • Anonymous
    November 24, 2011
    Again, a really clearly writen article. Thanks n keep it up. JK