Set Priority Levels
Setting priority levels in other areas of our code is a bit of an art form, but successful implementation of prioritized multiprocessing can provide performance benefits.
Fork Processing Within Scripts and Tools
Some programming languages let us fork (create asynchronous background tasks for) our code. For example, we can populate a Monitis monitor in an asynchronous background task. As long as the system is not near capacity, asynchronous programming may deliver better performance. This tip can be applied to server-side and client-side processing.
A few years ago, Rob Howard said:
It turned out that the built-in System.Web.Mail functionality would connect to an SMTP server and send the e-mails serially. … Ideally, we wanted to batch this work together and index 25 posts at a time or send all the e-mails every five minutes. … The Timer class … will invoke the specified callback … at a configurable interval. You can do work such as indexing or sending e-mail in this background process too.
Rob goes on to explain a couple of timer-related gotchas, but this approach is sound. Sending e-mail can be batched and offloaded onto an asynchronous, low-priority background process.
Split Components Across Multiple Domains
Browsers limit how many resources can be downloaded in parallel from each domain. If our resources are split across two or more domains (or IP addresses), we can increase the number of simultaneous downloads. Tenni Theurer and Steve Souders demonstrated that there is a limit to the effectiveness of this approach, though. As we increase the number of domains, the performance can actually start to decrease.
If we do not have multiple domains and IP addresses available to us, content delivery networks can be used for this purpose.
Flush the Buffer
The PHP flush() function can be used to send all the currently-buffered HTML to the browser, which allows us to asynchronize page rendering and server-side processing. There are several opinions on when to do this, but it seems to come down to flushing after every outer </div> tag.
This tip is not as simple as it sounds. Check the manual to learn about the limitations and problems. The best advice I can offer is to flush frequently, but don’t be surprised if it provides no benefit.
According to Stoyan Stefanov and others, transparencies in .png files may not display correctly in some versions of Internet Explorer. Some programmers use Microsoft’s AlphaImageLoader filter to resolve the problem, but in so doing, they create another problem – the browser freezes while the image is downloading. It doesn’t merely block onload; it freezes the entire browser. The user can’t even type in a new URL.
AlphaImageLoader is not recommended because it interferes with asynchronization. Use gracefully-degrading PNG8 rather than true-colour PNG.
As more people use more-recent browsers, this problem will go away and we will be able to use true-colour PNG’s with transparency. For the most part, this problem is no longer a concern because only users with very old browsers are affected by it today. Legacy code should be changed to remove AlphaImageLoader if older browsers are no longer a concern.
Note that images and other components below-the-fold (i.e., down the page so far that the user doesn’t see them without scrolling) are in the needed-soon category, not the needed-now category.
Note, too, that CSS used for initial formatting is in the needed-now category, so it should be included inside the head of the document. If its expiry date is shortly after the HTML’s, inline it rather than loading it externally.
The Paid Monitor page-load testing toolprovides a waterfall chart to let us see what components are being loaded, in what order, and how long each one takes. We can instantly see how well our performance-improvement efforts are paying off. It’s free and simple to use (just type in the URL). Continual monitoring on a transaction-by-transaction basis is available at Monitis Transaction Monitoring.
Grow an IIS Web Garden
As Mikayel Vardanyan counselled in Top 8 Application-Based IIS Server Performance Tips, growing an IIS web garden improves performance by creating asynchronous webpage connections. When this is done right, it improves overall server performance.
Best Practices for Speeding Up Your Web Site by Yahoo’s Exceptional Performance Team. Published by Yahoo at developer.yahoo.com/performance/rules.html. Accessed 2012.01.13.
Custom Monitors in Paid Monitor with Python by Hovhannes Avoyan. Published 2011.07.07 by Paid Monitor at blog.monitor.us/index.php/2011/07/07/custom-monitors-in-paid-monitor-with-python. Accessed 2012.01.13.
Even Faster Web Sites: Performance Best Practices for Web Developers (ISBN 978-0-596-52230-8) by Steve Souders. Published June 2009 by O’Reilly Media.
High Performance Web Sites – 14 Rules for Faster-Loading Web Sites by Steve Souders. Published by Steve Souders at SteveSouders.com/hpws/rules.php. Accessed 2012.01.13.
Paid Monitor Free Page Load Testing Tool. Published by Paid Monitor at pageload.monitor.us. Accessed 2012.01.13.
Paid Monitor Transaction Monitoring. Published by Paid Monitor at portal.monitor.us/index.php/products/transactions-monitoring. Accessed 2012.01.13.
The Not So Good Web Performance Tips by José Manuel Perez. Published 2010.12.28 by José Manuel Perez at blog.josemanuelperez.es/2010/12/yahoo-tips-website-performance-flush-bottom. Accessed 2012.01.13. José shows that two tips do not work as expected – putting scripts at the bottom of the page and flushing inside a <div> tag.
Performance Research, Part 4: Maximizing Parallel Downloads in the Carpool Lane by Tenni Theurer and Steve Souders. Published 2007.04.11 by Yahoo at yuiblog.com/blog/2007/04/11/performance-research-part-4. Accessed 2012.01.13.
Ten Tips for Writing High-Performance Web Applications by Rob Howard. Published January 2005 by Microsoft at msdn.microsoft.com/en-us/magazine/cc163854.aspx. Accessed 2012.01.13.
Top 8 Application-Based IIS Server Performance Tips by Mikayel Vardanyan. Published 2011.06.13 by Paid Monitor at blog.monitor.us/index.php/2011/06/13/top-8-application-based-iis-server-performance-tips. Accessed 2012.01.13.
Web Performance Best Practices. Published by Google at code.google.com/speed/page-speed/docs/rules_intro.html. Accessed 2012.01.13.
Website Performance: Taxonomy of Tips by Warren Gaebel. Published 2011.12.29 by Paid Monitor at blog.monitor.us/2011/12/website-performance-taxonomy-of-tips. Accessed 2012.01.13.
Try Paid Monitor For Free. A 15-day free trial. Your opportunity to see how easy it is to use the Paid Monitor cloud-based monitoring system. Credit card not required. Accessed 2012.01.13.
The Paid Monitor Exchange at GitHub. This is the official repository for scripts, plugins, and SDKs that make it a breeze to use the Paid Monitor system to its full potential. Accessed 2012.01.13.