Live data from Hacker News

Paul Buchheit: Make your site faster and cheaper to operate in one easy step

paulbuchheit.blogspot.com

21–30 of 60 posts

Re: Paul Buchheit: Make your site faster and cheaper to operate in one easy step

#21
For AJAX-based web applications, following is what I'd suggest in making things very zippy for the user:

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 :)

Re: Paul Buchheit: Make your site faster and cheaper to operate in one easy step

#22
post #20

Mibbit uses a custom webserver... Instead of gzipping things on the fly, I decided to just look for a .gz version on the filesystem, and use that if it's there. 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.

I don't know if this applies to your site or not, but if you have any dynamic http requests (non-cacheable) that approach doesn't work very well. You're much better off doing it on the fly with nginx as paul suggests; the impact on CPU is not noticeable even under very heavy load.

Re: Paul Buchheit: Make your site faster and cheaper to operate in one easy step

#23
post #22
post #20

Mibbit uses a custom webserver... Instead of gzipping things on the fly, I decided to just look for a .gz version on the filesystem, and use that if it's there. 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.

I don't know if this applies to your site or not, but if you have any dynamic http requests (non-cacheable) that approach doesn't work very well. You're much better off doing it on the fly with nginx as paul suggests; the impact on CPU is not noticeable even under very heavy load.

Yeah dynamic stuff is a whole different kettle of fish. The dynamic content on Mibbit is usually very small - maybe 100-200 bytes. The HTTP request headers are usually more (Which can't be compressed).

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.

Re: Paul Buchheit: Make your site faster and cheaper to operate in one easy step

#25
Blog entries like this make me feel truly educated. I could visit my grandparents in Weston, MA and regurgitate, "the highest merit we ascribe to Moses, Plato, and Milton is, that they set at naught books and traditions" and my grandmother would reply, "Ah, someone who is educated!" Whereas if I had said, "GZip encode your hypertext," she would be the uneducated one.

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.

Re: Paul Buchheit: Make your site faster and cheaper to operate in one easy step

#26
post #18

Earlier quoted context omitted.

Gzipping images is generally not a good idea. PNG/GIF/JPEG are already highly compressed and will probably grow in size if you attempt to gzip them.

PNG is often not well compressed unless you've gone out of your way to do so with PNGCRUSH ( http://pmt.sourceforge.net/pngcrush/ ) or something similar

I think this might be better? http://optipng.sourceforge.net/

Re: Paul Buchheit: Make your site faster and cheaper to operate in one easy step

#27
post #25

Blog entries like this make me feel truly educated. I could visit my grandparents in Weston, MA and regurgitate, "the highest merit we ascribe to Moses, Plato, and Milton is, that they set at naught books and traditions" and my grandmother would reply, "Ah, someone who is educated!" Whereas if I had said, "GZip encode your hypertext," she would be the uneducated one. So education is relative. Perhaps if I give in and…

i don't think i understand your comment, but it was pretty entertaining, nonetheless.

Re: Paul Buchheit: Make your site faster and cheaper to operate in one easy step

#28
post #25

Blog entries like this make me feel truly educated. I could visit my grandparents in Weston, MA and regurgitate, "the highest merit we ascribe to Moses, Plato, and Milton is, that they set at naught books and traditions" and my grandmother would reply, "Ah, someone who is educated!" Whereas if I had said, "GZip encode your hypertext," she would be the uneducated one. So education is relative. Perhaps if I give in and…

i don't think i understand your comment, but it was pretty entertaining, nonetheless.

It was casual. But truthful in sentiment. You can see it as ironical in that I was educated by the Internet and not by being in the Bay Area. Yet, being in the Bay Area, making the right friends, and appropriately asking the right questions and exchanging ideas may prove more useful than the Internet, sometimes. (After all, the Internet is still by your side if you need it.)

Re: Paul Buchheit: Make your site faster and cheaper to operate in one easy step

#29
post #21

For AJAX-based web applications, following is what I'd suggest in making things very zippy for the user: 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 st…

While it's true that IE6 and IE7 can only handle 2 concurrent persistent connections per server, IE8 can handle 6.

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.

Re: Paul Buchheit: Make your site faster and cheaper to operate in one easy step

#30
post #28

Earlier quoted context omitted.

i don't think i understand your comment, but it was pretty entertaining, nonetheless.

It was casual. But truthful in sentiment. You can see it as ironical in that I was educated by the Internet and not by being in the Bay Area. Yet, being in the Bay Area, making the right friends, and appropriately asking the right questions and exchanging ideas may prove more useful than the Internet, sometimes. (After all, the Internet is still by your side if you need it.)

I'm about to skedaddle from the Bay area, and can't say it's really worth the expense of living here. You know when people start spouting off about the supposed virtues of living in an area they're probably in real estate; at the very least, they likely have financial interest in property. At least the Internet does one thing very well, and that is expose greed and stupidity. With such a high concentration of greed (high rents) in an area, it's not surprising to find such a high concentration of stupidity. There are at least 49 other states far more deserving of my tax dollars.
Post reply on HN