Archive for July, 2008

Speeding up page impressions

I had cause to review a web servers performance recently after it was noted that one site was being served extremely quickly to the client and the other seemed woefully slow.

Well the webserver in this case was IIS 5 but the ideas discussed are relevant to other webservers such as Apache.

Firstly utilising a couple of excellent plugins for the FireFox 3 browser, namely Firebug and YSlow for Firebug, I was able to instantly see performance stats about how a server is serving a page to the client.

It was clear that the site I was reviewing wasn’t using any settings for caching and also wasn’t using gzip compression for on the fly compression of the HTTP response.

These sorts of thing can generally be set in a number of ways – either in server side script or configured for a given resource.

So, to summarise the changes I made in IIS for this site, I made sure all images were being stored in a folder called images from the root of the site. Then from IIS snapin right click the folder and choose properties, choose the HTTP Headers tab and enable content expiration for images.

Next I enable gzip compression by right clicking the computer icon in IIS and clicking properties, then choosing Edit under Master Properties and clicking on the Service tab – yeah pretty well hidden away really.

Under IIS if you choose to “compress application files” only the following will be compressed “asp”, “dll”, “exe”, I know this is true of IIS 6 as well as IIS 5 – search google for “Customizing the File Types IIS Compresses” to see how to get round that – you’ll likely want to add aspx and php if your server is supporting them.

Here’s the contents of a batch file that can be run on the server to set this up, just make sure that adsutil.vbs is available where the script is looking.

IISreset.exe /stop
cd c:\Inetpub\AdminScripts
cscript adsutil.vbs set w3svc/filters/compression/parameters/HcDoDynamicCompression true
cscript adsutil.vbs set w3svc/filters/compression/parameters/HcDoStaticCompression true
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcFileExtensions "htm" "html" "txt" "ppt" "xls" "xml" "doc" "js" "css"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcFileExtensions "htm" "html" "txt" "ppt" "xls" "xml" "doc" "js" "css"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcScriptFileExtensions "asp" "dll" "exe" "aspx" "asmx" "ashx" "php"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcScriptFileExtensions "asp" "dll" "exe" "aspx" "asmx" "php"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcDynamicCompressionLevel "9"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcDynamicCompressionLevel "9"
IISreset.exe /restart


By Matt in Systems, web  .::. (Add your comment)

Improving System Performance

I’m often asked by clients as well as friends and family whether or not I am able to speed up their Windows machine as they perceive it to have slowed to a crawl.

I don’t like to use third party software for such tasks as to be truthful I don’t trust them – besides if you’re comfortable making a few changes then these tips are free.

So I put together a list in no particular order of things I do that will improve performance:

  • Firstly – grab a copy of the Sysinternals Suite of utilities from Microsoft – they really are great and they are free to download and use.
  • Process Explorer (procexp.exe) is much better tool than Task Manager for viewing running processes and looking at what’s going on.
  • Autoruns (autoruns.exe) is a great tool to let you see what programs are configured to run when Windows is started. These days there are many places in the registry and other methods that a developer can use to get their code running. This tool means you don’t have to remember them all, you can view them all in one place and disable or enable them at will.
  • Clean out the Temp directories – the amount of times I’ve seen many hundreds of Mb of files sitting in a users Temp folder, you can write a script (or go find one) to clear this area out on System Shutdown though I don’t think that’s necessary.
  • Pagefile – there are a few things you can do to the pagefile to improve system performance. Firstly on any modern machine with 512Mb ram or more you could try changing the page file size to be 1:1 with the amount of ram the machine has. Secondly you can use System File Defragmenter (pagedfrg.exe) again from Sysinternals to defragment the pagefile.sys on the next reboot or on every reboot. And thirdly you could move your pagefile to a new partition on your disk or even better to a separate physical disk. This will improve access times to the file and also help prevent it from getting fragmented again.
  • Disable Indexing Service – you can benefit from improved system performace with this service set to disabled on a less powerful machine. Searching for files will be slower though.
  • Folder browsing – Uncheck the Automatically search for network folders and printers checkbox. This is in explorers Tools | Folder Options under the View Tab. More suited for a home computer that doesn’t connect to a network.
  • Desktop Background Picture - a little desperate but just make sure that the user hasn’t selected some huge image file taken on a high resolution camera or something.
  • Disable Services that are not necessary. There are many lists online about what services can be disabled – so I won’t add to them here. Just be a little careful with this one as an application may depend on a service – if it’s a business system you don’t want to break your client’s apps.
  • Swapfile performance – run msconfig.exe. On the System.ini tab expand 386enh and add a new setting that reads “ConservativeSwapfileUsage=1″ without the quotes. Then restart. This should force your system to use all available ram before it starts to use the swapfile.
  • DMA setting for the Primary IDE Channel under IDE ATA/ATAPI controllers should be a DMA mode not PIO. This is set by default make sure it hasn’t changed for some reason. The setting is found under Device Manager.
  • To improve perceived shutdown speed on a machine that seems slow you can try the following registry tweaks:

HKCU\Control Panel\Desktop\WaitToKillAppTimeout = x milliseconds.

Try changing it from it’s default value of 20000 to 5000.

HKCU\Control Panel\Desktop\AutoEndTasks = 1  

This will force the system to close processes automatically when the user attempts to log off or shut down.

After all that hardware improvements will always yield the biggest improvements in a systems performance so consider these:

Upgrade ram

Throw out your IDE hard disk and put in a SATA drive they are much faster.

 


By Matt in Systems  .::. (Add your comment)


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.