Saturday, May 8, 2010

Web application Performance First Aid

Below I tried to list down a few question or hints to focus whenever there is performance issue.

Front end:
1. Is page too heavy?
2. Is content poorly cached?
3. Is content not compressed?
4. Is javascript & css minified?
5. Combine CSS and JS files to reduce the number request for these resources
6. Is there any inline javascript or CSS – move it to external file?
7. Place the javascript and css appropriately
      1. Javascript at the end of the body
      2. CSS at the head.
8. Can static content like CSS and JS be akamized?
9. Restructure the folder and enable cache by folders like css, js, image and set the cache setting at these folders at webservers
10. Can resources be pre-fetched like we expect user to click a few links and we can preload those image in the home page.
11. Can content be published to CDN?
12. Is CDN configured appropriately?
13. Can image be compressed? Smushit?
14. Can we use multiple domain for resources for simultaneous downloads?
15. Cookies less domain for image resources?
16. Can we club images using the CSS-Sprite technique?
17. Sometime ETAG can cause issue, different server have a way to manage this
18. Scope of AJAX-fying the pages
19. Cookie size
20. Is number of request per page back to server including all resources in acceptable range around 15-20? Is it possible to reduce it?
21. Has the page been tested in low bandwidth scenario?
22. Is it possible to host the resource server separate from the main web server?
23. Use appropriate robot.txt to avoid search engine traffic
24. Using libraries to deal with DOM like JQuery etc

Middle tier
1. What is the technology stack?
   1. Tech specific optimization
2. Scope of web server caching?
3. Response buffering
4. Page and control fragment caching
5. Façade approach – in case of multiple service call can be clubbed
6. Is there any web service call, wsdl caching issue?
7. Is it possible to segregate anonymous and non-anonymous pages?
8. Is there any integration services
9. Is there any 3rd party system integration
10. Is it using Store-proc or can application use store proc?
11. Reverse proxy to manage the static content
12. Enable HTTP Keep-alive
13. Excessive logging
14. Distributed Caching in case of load balanced environment

 Give a shot to backend
1. Store procedure usage
2. Indexing and index column data types
3. Is Database statistics up to date?
4. Check defragmentation
5. Choosing approach log level. In case of SQL server we have simple, full etc mode.
6. Archiving to reduce the records
7. Choosing database inserts over updates if possible
8. High I/O queries
9. High table scan queries
10. In case database like MySQL – can we use appropriate engine for different kind of tables?

Tool to analyze
1. Measure the front end application - Yslow or PageSpeed plug-in for firefox
2. Measure the application middle tier
   1. Performance monitor log
       1. Web server specific
             1. Request Per second
             2. Request Queue
             3. Request Processing Time
             4. Request Errors
             5. Cache Hit
        2. Disk I/O 
        3. Peek memory usage
        4. Peek CPU usage
3. Measure the backend layer
  1. SQL Profiling in case of MS SQL
  2. CPU usage
  3. Logical and Physical Reads
  4. Execution Time
  5. Monitor for DB Locks
  6. Analyze slow running queries using execution plan


See if we can do anything without code change:

1. Server changes
Restructure the folder and enable cache by folders like css, js, image and set the cache setting at these folders
Gzip the content
Reverse proxy to reduce traffic on primary server
Separate the resource request and page request in to 2 farms – like media farm (hosts media content like images, files, videos etc) and web farm (host the main application)
2. Database
Index fine tuning
Statistic updates
Optimizing top 10 slowest queries :)
3. Infrastructure upgrade
Upgrade the server system configuration