Paul Buchheit: Make your site faster and cheaper to operate in one easy step
paulbuchheit.blogspot.com
paulbuchheit.blogspot.com
1. Concatenate your JS and CSS files. Don't send out several files over the wire to the browser - the browser can only make 2 connections at a time. Be careful about JS dependencies - order is imp. in JS.
2. Minify and then compress the JS and CSS. Use Dojo's Shrinksafe or the YUI Compressor to do this. It will strip out whitespace, etc - make the code smaller in size (In JS, every byte counts) and compress.
3. Now gzip the above. (Paul's article talks only about gzipping - if you do the above 2 steps as well, you'd improve the performance a lot more).
Write an Ant script to automate all the above on code commit and you are done. Try other methods like loading other elements in the background or after a tab etc is clicked - important to show something to the user almost instantly. Did this for Alertle.com, which was a 100% AJAX web app (no page refresh at all), and the initial size of the code being sent to the browser went from 700k to about 20k using the steps above :)
Firefox 3 by default handles max 8 persistent connections per server, and max 15 connections per server in total (persistent and non-persistent).
This goes against RFC2616, but I guess the capacity of both servers and clients have increased enough the last 10 years to warrant such changes in default behavior across browsers.
This is slowly becoming not true anymore, decent browsers like Opera and Firefox have defaulted to 8 for a while now, and IE8 defaults to 6.
Although all your points are still valid.
Improving site speed is a broad topic, and there would be other stuff on the server-side too where improvements can be made, like cached queries and using "prepared statements" to optimize the SQL.
The same applies for S3 uploads. You can pass cache headers in the upload request which will later be used on all downloads.
If you're really worried about the performance hit of gzipping, you can cache gzipped versions of static resources.
500KB is pretty huge. Does every user need that? Perhaps you can use a smaller bootstrap script to pull down only what's needed when it's needed.
http://developer.yahoo.com/yslow/ http://developer.yahoo.com/performance/rules.html
So education is relative. Perhaps if I give in and move to the Bay Area my education will be richer than I would ever have imagined.
Either way, I don't think knowing to GZip your pages counts as "education" any more than knowing how to put a horse shoe on a hoof or how to facilitate a corporate merger does.
Tip: stay out of the Bay Area but not too far, maybe to San Jose and keep in touch with a few buddies, but not to those who you truly don't like.
eg a request for 'index.html' looks for 'index.html' and 'index.html.gz'. If the gz is there it uses that and sets headers accordingly.
Works incredibly well, and the deploy scripts just gzip things when they're pushed out to production.
For Mibbit, I'd like to eventually do my own compression which will beat the socks off gzip, as it'll be session based rather than per request.
But yeah, I can see use cases where you're sending dynamic stuff which will benefit from gzip and where pre-caching on disk doesn't really make sense.
Mibbit uses some cool Comet like stuff, and I'm 99% confident the Mibbit webserver is better than anything else at doing this.
I'm constantly amazed by the people who think writing HTTP servers is really hard.
Writing an HTTP server is easy. But making one that handles long lived connections (10s of thousands), and scales well, doesn't eat memory, doesn't eat CPU, etc etc is harder.
Having said that, it's easy enough that I think it's often worth doing if the webserver is integral to your success (It is with Mibbit).
My main point was that it would be hard to tell if someone somewhere had an HTTP implementation that could handle 250 000 concurrent HTTP connections per 64MB of RAM while yours only handled, say, 5000 per 64MB. (I suspect the former number is achievable; I know the latter is.)
I can confirm from experience that writing an HTTP server that scales well without eating memory or CPU is dramatically harder than just writing an HTTP server. However, it's very easy to do better than apache-mpm-prefork. (No need, though; lighttpd and nginx should both do better at that, I have heard that perlbal does too, and I suspect from experience that twisted.web does as well, although I haven't measured it.)
/etc/init.d/apache2 restart
Smaller pages are actually faster (both individually and collectively), though gzip is already fast enough that the difference is irrelevant.
I had an image that pngout got to 218K (221K for optipng). pngnq chopped that thing to 74K. When flipping between the images you could see some pixels change, but only if you looked really hard.
(Running pngout on that image brought it down to 71K. Nice.)