Optimizing Page Load Times
John Callender writes, "Google engineer Aaron Hopkins has written an interesting analysis of optimizing page load time. Hopkins simulated connections to a web page consisting of many small objects (HTML file, images, external javascript and CSS files, etc.), and looked at how things like browser settings and request size affect perceived performance. Among his findings: For web pages consisting of many small objects, performance often bottlenecks on upload speed, rather than download speed. Also, by spreading static content across four different hostnames, site operators can achieve dramatic improvements in perceived performance."
I'm not quite sure how this really has any "real world" effects.. Browsing speed is already insanely fast to the point where if you blink you miss the loading on most connections these days. How does speeding up this second or so really help anything?
I can see it's use on large sites but this seems aimed at smaller sites.
Then again HTML isn't my thing so it goes over my head I guess.
I like muppets.
If the user were to enable pipelining in his browser (such as setting Firefox's network.http.pipelining in about:config), the number of hostnames we use wouldn't matter, and he'd make even more effective use of his available bandwidth. But we can't control that server-side.
i ning-faq.html
For those that don't know what that means: http://www.mozilla.org/projects/netlib/http/pipel
I've had it switched on for ages. I sometimes wonder why it's off by default.
http://twitter.com/onion2k
From TFA:
And:
From RFC 2616, section 8.1.4:
It's not a browser quirk, it's specified behavior.
"Regularly use your site from a realistic net connection. Convincing the web developers on my project to use a "slow proxy" that simulates bad DSL in New Zealand (768Kbit down, 128Kbit up, 250ms RTT, 1% packet loss) rather than the gig ethernet a few milliseconds from the servers in the U.S. was a huge win. We found and fixed a number of usability and functional problems very quickly."
What (free) simulation is available for this? I only know dummynet which requires a linux server and some advanced routing. But surely there is more. Is there?
I've worked with heavily loaded servers that serve many pictures per page and can confirm that this does decrease perceived load time, but it does have its drawbacks. Pushing the concurrent browser requests to num_hostnames * browser_default on the same physical host, you'll have to increase the maximum concurrent requests of your web server, which can badly increase system load and lead to easy slashdotting situations. Only do this if you can modify those settings, know what your server is capable of and are not limited by bandwidth as this can also quickly fill your tubes. And as the article states: only do this with small objects or you might be under heavy load in no time.
:/- spoon(_).
I've done some benchmarks and measurements in the past which will never be made public (I work for Yahoo!). And the most important bits in those have been CSS and Scripts. A lot of performance has been squeezed out of the HTTP layers (akamai, Expires headers), but not enough attention has been paid to the render section of the experience. You could possibly reproduce the benchmarks with a php script which does a sleep() for a few seconds to introduce delays at various points and with a weekend to waste.
The page does not start rendering till the last CSS stream is completed, which means if your css has @import url() entries, the delay before render increases (until that file is pulled & parsed too). It really pays to have the quickest load for the css data over anything else - because without it, all you'll get it a blank page for a while.
Scripts marked defer do not always defer and a lot of inline code in <script> tags depend on such scripts that a lot of browsers just pull the scripts as and when they find it. There seems to be just two threads downloading data in parallel (from one hostname), which means a couple of large (but rarely used) scripts in the code will block the rest of the css/image fetches. See flickr's organizr for an example of that in action.
You should understand that these resources have different priorities in the render land and you should really only venture here after you've optimized the other bits (server and application).
All said and done, good tutorial by Aaron Hopkins - a lot of us have had to rediscover all that (& more) by ourselves.
Quidquid latine dictum sit, altum videtur
You see this in forum html where they have inlined hundreds of lines of js and CSS, this increases response size per request. The page will display faster first time but the correct thing to do is set expires headers and have the browser cache external CSS and javascript files. It's a tradeoff, larger CSS segments and javascript that are used site-wide should always be external, 200 bytes in a head element thats sent over the wire using gzip (because deflate confuses some browser vendors) is probably not worth bothering with.
Just what we need in the time of phising attacks being a constant worry: having to figure out whether not just one, but four different hostnames belong to the site operator in question.
Oh, I can't help quoting you because everything that you said rings true
This is a good place to start testing the 'cacheability' of your dynamic web pages. Quite frankly it's appauling that even the big common web apps used today like most forum or blog scripts don't generate sensible Last-Modified, Vary, Expires, Cache-Control headers. With most of the metadata you need to generate this stuff stored in the existing database scheme theres just really no excuse for it.
Abolishment of nasty long query strings into nicer, more memorable URI's is also something we should be seeing more of in "Web 2.0." Use mod_rewrite, you'll feel better for it.
If a big part of your job involves using a Web-based application, reducing page-load times really helps. My real job is writing one of these applications and getting the caching right is much more important than sexier topics like AJAX. There's some good advice in TFA.
Reduce, reuse, cycle
FTFA:
``Neither IE nor Firefox ship with HTTP pipelining enabled by default.''
Huh? So all these web servers implement keep-alive connections and browsers don't use it?
Please correct me if I got my facts wrong.
``By default, IE allows only two outstanding connections per hostname when talking to HTTP/1.1 servers or eight-ish outstanding connections total. Firefox has similar limits.''
...) in it (i.e., most web pages), and lots of these objects are going to be requested sequentially, costing you lots of round trip times.
Anybody know why? This seems pretty dumb to me. Request a page with several linked objects (images, stylesheets, scripts,
Please correct me if I got my facts wrong.
Pipelining depends on keep-alive to concatenate multiple HTTP responses into a single TCP packet.
FTFA:
``Most DSL or cable Internet connections have asymmetric bandwidth, at rates like 1.5Mbit down/128Kbit up, 6Mbit down/512Kbit up, etc. Ratios of download to upload bandwidth are commonly in the 5:1 to 20:1 range. This means that for your users, a request takes the same amount of time to send as it takes to receive an object of 5 to 20 times the request size. Requests are commonly around 500 bytes, so this should significantly impact objects that are smaller than maybe 2.5k to 10k. This means that serving small objects might mean the page load is bottlenecked on the users' upload bandwidth, as strange as that may sound.''
I've said for years that HTTP requests are larger than they should be. It's good to hear it confirmed by someone who's taken seriously. This is even more of an issue when doing things like AJAX, where you send HTTP requests and receive HTTP responses + XML verbosity for what should be small and quick user interface actions.
Please correct me if I got my facts wrong.
Isn't using 4 subdomains going to confuse the google algoritem (abuse of subdomians has beeen adressed in a few updates) let alone duplicate content - or is it just for iamges and objects.
You will never get to heaven with an Ak 47... But A Zu 30 is good for Low Flying Cherubim
Latency matters a lot. My connection does up to 512 KB/s downstream, meaning a 10 KB object would take about 0.02 seconds to receive. However, before I start receiving the bytes, my request has to travel to the server, and the response has to travel back to me. When the site is in the US (I'm in Europe) the round trip time to the server can easily be 100 to 200 ms. If the TCP connection is already open, this time gets added once. However, if the connection still has to be established, this will result in another round trip time being added. So, because of the latency, that 0.02 seconds becomes 0.03 through 0.06 seconds, instead.
If you read the article, you will see that the default behavior for Firefox and MSIE is to use only up to two connections per hostname (resulting in many objects being received sequentially - add one round trip time for each), and that they don't use HTTP pipelining, meaning a new connection is set up for each object (add one round trip time for each).
In other words: it's the latency, stupid.
Please correct me if I got my facts wrong.
I hope they apply this study on Gmail. Using it on a non-broadband connection (plain 56k modem) is a pain unless you use the pure HTML view that is crap compared to other HTML webmails.
The fun is that newer AJAX products from google (like goffice) don't suffer from this behavior, they have a much more cleaner code (just pick view code on your favorite browser and see). Probally Gmail HTML/Javascript is already showing it's age, and paying the price for being a first at google AJAX apps.
Since every fricking developer seems to think that the web is the end all be all future solution for everything, then yes, it does matter.
When I click on an element in a web page to manage my email or use a word processor, the response time is going to be around my ping (30-90 ms depending on where in the country it is) plus the time to load. That is long enough that I am clicking, and waiting. If I were working on a local native app, the response time would be under 30 ms and I would probably not even notice it.
For a quick email check or reading webpages, it doesn't really matter too much. But if you're trying to use that for constant daily productivity sorts of things (or even have a lot of email to go through) it is wasting a ton of your time. There are some real advantages to moving applications online and into a web browser (I've even heard people suggesting we should move to a web-browser for the full interface of our windowing system) but speed is currently NOT one of them. Since it seems like it's going to be more or less forced on me, anything that can make it faster and more tolerable is quite appreciated.
I've had it switched on for ages. I sometimes wonder why it's off by default.
Some reasons against pipelining.
There is a paper about this in SIGCOMM 1997 (!) by Nielsen, Gettys, et al that goes into far more detail of the "whys" and "wherefores". I'm not sure this shows ANYTHING new. In fact, what this gentleman demonstrates is the way that TCP windows work. By spreading requests over four hosts you are in effect getting four times the window size, arguably more than your fair share. Without looking at the aggregate impact, one cannot really judge what's going on.
Also, the reason pipelining is turned off by default in many browsers is that there are a lot of middleboxes that can't handle it.
There are a lot of posts here asking "why is this important" and saying that pages already load fast enough on their broadband Internet connection. That may be true for you, but I'm frequently in a position where I am designing a site that needs to load over a slow satellite connection in rural Africa, say, or into a remote village in Nepal. They have a fairly recent computer, OS and browser on the recieving end, but their Internet connection is dog slow; anything I can do to speed it up will be greatly appreciated. It's back to 1980s dial-up speeds.
This isn't everyone's problem, I admit, but it's an issue for a lot of people in the world.
$nice = $webHosting + $domainNames + $sslCerts
How ironic that a google engineer would say this, since doing this will also pretty well kill your google pagerank rankings. Google is great, yes, but among is many, many problems are the ridiculous ways that it forces people to do web design if they want a decent pagerank. another is how it "helpfully" directs you to "geographically relevant" searches - meaning that, for example, if you want a hotel room in egypt and browse from the UK, you get all the links from (much more expensive) UK based hotel and travel shops rather than, say, ones in egypt or elsewhere that, while also in english, are much cheaper.
Read the faq. It is a vey simple webserver in java. Not a proxy.
"Sloppy doesn't work as a real HTTP proxy so don't configure your browser to use it."
Nice trick with 4 hostnames, but this means 4 security contexts for your content, which may make a lot of development hard (especially client based with JavaScript).
Not to mention the management issues of having to link to content on 4 different domains in an efficient enough manner.
This leaves us with pipelining on the client, which could results in much worse load peaks on the servers though.
In the end: let the page load a little slower, the workarounds are not worth it.
Use public proxies -- they are usually very slow.
this is an interesting summary about network affected display time. i would like to add that nowadays, with more complex pages, the rendering time has also to be taken into account. for example; with the use of bloated/redundant/unneeded css declarations, java and flash applets the pageload (until it is actualy display to the user) can be slowed down pretty badly. if you don't belive me, go an check out myspace.com :P
Cheers,
-S
Ok, now how will this help the loading of Slashdot? In that Slashdot has this terrible habit of occasionally slowing the browser to a halt when opening discussions with a lot of posts to parse (I'm using the new discussion system).
The problem, as I see it, is that issues like page load times are partly caused by browser issues (HTTP pipelining, cache, etc) and partly caused by server issues. (yes, yes, I know it's obvious) However, consider the idea of specialized configurations. Essentially a per-site set of conditions. For Slashdot.org, allow multiple HTTP connections (have to load that style file) and just load the images from the old cache (after all, the Microsoft Borg icon hasn't changed, has it?)
To a certain extent, this could be handled almost in a cookie-like fashion, except it's read before the initial HTTP request is made. You'd know that you're only requesting parts of the page, and could do a background query for elements which have been updated (i.e. a new category image, etc).
Then again, I also hate it when the loading of a PDF causes a loss of focus and slowing of the browser. Not the same, but in the same category of annoyance.
-
It's obvious how much you identify as part of the slashdot community. I mean, only dedicated slashdotters would go to the trouble to adblock the few banner adverts on this page just so they can get to the comments faster. That's a clear sign that you care more about the good of the community than yourself. I just wanted to say: Thank you for making such a commitment to this website. If everyone took the extraordinary steps to block completely unobtrusive advertising than this website would be a much better place.
We all know that slashdot doesn't NEED advertising revenue. It's a little-known fact that Slashdot servers don't need bandwidth or electricity: You just pour a four-pack of redbull directly into the gigabit ethernet port and it serves requests like a daemon for 2-3 days without needing to sleep().
So what happens if a user, or A LOT of users increased their default connection limit to >2 ?
For example, say a popular browser in it's next release had a default of 10?
What would be the effect on servers (small and large)? Would it help everyone? Do servers reject >2 connections by default?
I am on a T3 connection at school and I don't notice any speed difference from my home cable connection (3mbit down 256k up). Then again I am comparing Internet Explorer 6 to Firefox 2 at home with all settings maxed out in fasterfox.
Maybe blogger.com went to implement this ? Silly! It's the old hardware problem http://news.zdnet.co.uk/internet/0,39020369,392843 79,00.htm
We don't all have googles resources and with broadband connection speeds increasing, many admins are finding it prudent to throttle bandwidth. An additional 10Mbps of transit doesn't come cheap. How many of the people wanting to make more connections are prepared to pay site subscriptions to make these connections worthwhile?
:-o
Net Neutrality eat your heart out
Has anyone played around with multipart/mixed or such replies? These could reduce the number of requests but is there any support for them in browsers?
You pompous asshat.
Ever try to set the timeouts for static content to 40 years in the future. Then the browser won't check to see if there's a new version for all those little images, HTML snippets and javascript files. When you upgrade, just put the new files in a different directory to force the download. Basically take control of the automated download process.
google writes research papers which are published on slashdot.
What next? Buy youtube? er..
This is an excellent argument for ad blocking. The article never mentions the basic truth - almost all offsite content on web pages is ads. (Of course, this is someone from Google talking, and Google, after all, is an ad-delivery service which runs a search engine to boost their hits.) Web page load is choking on ads. I noted previously that some sites load ads from as many as six different sources. This saturates the number of connections the browser supports. Page load then bottlenecks on the slowest ad server.
So install AdBlock and FlashBlock in Firefox, and watch your browsing speed up.
Web-based advertising looks like a saturated market. Watch for some big bankruptcies among advertising-supported services.
PARENT IS AN ANONYMOUS COWARD
So MythTV is still guessing, like the ad-skipping VCRs of twenty years ago.
There's better data available. Broadcast TV signals contain considerable metadata. The AMOL data in the VBI and the SID data in the audio clearly identify the program content and source. Here's a encoder for that information, which is inserted to make Nielsen ratings and advertising payments work.
See U.S. patent #5,699,124 for some details of how the data is encoded.
So far, the PVR community doesn't seem to have figured this stuff out, and the specs aren't easy to get, but the data is out there.
Meant to post that in the MythTV article. Oops.
E.g., Cisco's AVS (formerly Fineground): http://www.cisco.com/en/US/products/ps6492/product s_white_paper0900aecd80321a32.shtml
- implements the multiple DNS name solution suggested by Mr Hopkins
- has a clever way of eliminating browser cache validation requests
- has a mechanism to transparently measure actual (not simulated) user page load times
Other products have similar but, in this age of software patents, slightly different optimizations:Check out this page and it's source. Every img tag has a height & width component. The values are different from the size of the actual image, causing the browser to resize every image. This is insanely stupid. I especially like that the images used as dividers, shown multiple times on the page, are forced to a different size each time: Yellow_back.gif and yellow_back.gif
Do the absolute position tags cause a slowdown in rendering? I would expect that a rendering engine would be optimized for standard html, not absolute page layout. Note that these tags also corrupt the layout of the page when the font size is changed in the browser.
I just spent several minutes - three times - waiting for the front page to load because the browser was sitting there waiting on "runner.splunk.com" to get off its ass and do something.
Guys, splunk does not apparently have the server power or bandwidth to service Slashdot. Get a clue and dump their ads or tell them to buy another server box.
Ninety percent of the time when I'm waiting on a page to load, it's because some ad server is overloaded. The rest of the time it's because the site server itself is overloaded (or "Slashdotted").
Use Firefox - then use Adblock generously.
Richard Steven Hack - This sig is TOO GODDAMN SHORT TO DO ANYTHING USEFUL WITH! MORONS!
Turn on pipelining and use more connections per host with this Firefox-Add-on
Tweak Network Settings:
http://www.bitstorm.org/extensions/tweak/
Very easy to use: just use the "Power profile".
Me
Pipelining is: You send a bunch of requests, the server sends a bunch of responses. This is good because it reduces round-trips -- you can send requests without waiting for the replies, making it very useful over high-latency connections. It must send the responses in exactly the order you requested them.
This is potentially bad, because it means a 5k gif can be queued behind a 200k SWF, and there's nothing anyone can do about it once they're queued up like that. The right approach is to use multiple connections -- there may be a bunch of round trips, but most likely, at least one of your connections will be busy, so your pipe stays saturated, and more importantly, things appear to load faster that way -- the smaller parts of the page will all be done quickly, even if someone sticks a 2 meg jpeg in the middle.
The downside of multiple connections is the overhead in opening them -- but if BitTorrent can work, so can this. It might be a harder hit on the server side, though. The other nice thing about pipelining is persistence -- you send your huge batch'o'requests through the same pipe, instead of sending a request, getting a reply, then opening a brand new connection for a new request. But, you can do persistence without pipelining -- open a connection for every file you need (up to your arbitrary browser-defined limits), then as files finish downloading, re-use the existing connections, only closing them when you don't need any more files.
Now, it's possible that some web servers might do better with pipelining, and certainly there are servers that won't do persistence any other way. Pipelining a single connection is easier on the server than handling a dozen connections. But if you both can handle it, disabling pipelining is the way to go.
I wish I could find the place I read this (last night), but I can't. I believe it's linked to off of Opera's explanation page, but I don't remember what that is, either.
Don't thank God, thank a doctor!
The maximum number of simultaneous connections for Windows applications using the WinInet API (including Internet Explorer 4+) is determined by the following registry DWORD values:
These two settings affect HTTP 1.0 and 1.1 connections respectively and default to 4 and 2 respectively. More info (including similar tweak for Firefox).
For tweakers that won't leave sleep over hogging extra web server cycles, you can increase these limits to significantly reduce page load times. If the values don't already exist, go ahead and create them (DWORDs). A reboot will be required. The IE dev team have unofficially recommended setting both to 16 (decimal, 10 hex) for best performance.
Of particular note is the direct effect that these settings have on the maximium number of simultaneous file downloads allowed in IE.
~ PSdiE