Some Tips To Improve Performance Of Your Web-Application
June 13, 2010 Leave a Comment
What Slows your site down? (Most expensive to least)
- Database write access (read is cheaper)
- Database read access
- PHP, ASP, JSP and any other server side scripting
- Client side JavaScript
- Multiple/Fat Images, scripts or css files from different domains on your page
- Slow keep-alive client connections, clogging your available sockets
How to make your site run faster
-
Database layer
- Switch all database writes to offline processing.
- Minimize number of database read access to the bare minimum. No more than two queries per page.
- De-normalize your database and Optimize MySQL tables
- Implement MemCached and change your database-access layer to fetch information from the in-memory database first. The least you should do is store all sessions in memory.
- If your system has high reads, keep MySQL tables as MyISAM. If your system has high writes, switch MySQL tables to InnoDB. If you need 99.999% availablity – consider switching to MySQL Cluster storage.
-
Server side scripting
- Limit server side processing to the minimum.
- Short scripts that queue any heavyduty processing to be done offline. Use a caching engine that generates static files from dynamic ones, so that processing only takes place once.
- Per-compile all php scripts using eAccelrator. If you’re using WordPress, implement WP-Cache
-
Front end
- Reduce size of all images by using an image optimizer, Merge multiple css/js files into one, Minify your .js scripts
- Avoid hardlinking to images or scripts residing on other domains.
- Put .css references at the top of your page, .js scripts at the bottom.
- Install FireFox FireBug and YSlow. YSlow analyze your web pages on the fly, giving you a performance grade and recommending the changes you need to make.
-
Web Server
- Optimize httpd.conf to kill connections after 5 seconds of inactivity, turn gzip compression on.
- Configure Apache to add Expire and ETag headers, allowing client web browsers to cache images, .css and .js files
- Consider dumping Apache and replacing it with Lighttpd or Nginx. If you absolutely need to stick with Apache – upgrade to its latest version.
-
The Results
- Implementing the steps described above will result in a faster browsing experience for your visitors as well as significantly improved website scalability.
- The chart below illustrates heavy load impact on a non optimized machine (linear degradation in performance) vs an optimized machine.
- With our non optimized machine, CPU spiked to 90% with 50 concurrent connections. The optimized machine was effectively handling 500 concurrent connections per second with CPU at 8% and no degradation in performance.
Advertisement
Recent Comments