Mar 08

http-pipeline.gifDefined here by Wikipedia.org, “HTTP pipelining is a technique in which multiple HTTP requests are written out to a single socket without waiting for the corresponding responses.

Mozilla talks a bit more about the topic: “Normally, HTTP requests are issued sequentially, with the next request being issued only after the response to the current request has been completely received. Depending on network latencies and bandwidth limitations, this can result in a significant delay before the next request is seen by the server.

I have accepted the fact that HTTP pipelining is pretty much disabled in all modern browsers, but that doesn’t mean I have to like it!

I have a widget in Firefox that allow me to bypass this missing “feature” and it sure seems to speed up my browsing quite a bit. However, why can’t everyone get together and work this problem out so we don’t need extensions/widgets/hacks to get around the limitations?

I attempted to harass Microsoft about it and never received an answer (I didn’t really harass them per say). Firefox isn’t mum on the subject (here), but it seems to come down to compatibility issues with certain servers, routers, et cetera in some specific cases (even if the HTTP/1.1 spec allows it).

So what does a web developer do (programmatically)?

Do we just accept the fact and move on or is there something we can do about it? How can we speed up our page loads to a world that can’t use pipelining?

It turns out there is a relatively simple way to “fake HTTP pipelining”. When I read through the article “Optimizing Page Load Time“, I had a very revealing moment of self-inflicted-disrespect. The solution is so obvious, but it never dawned on me previously. Why not simply source content on the page from different locations? It doesn’t even have to be different servers, just different domains. Pretty simple right?

For example, we could do something like this for a single web page:

- Static Images: images.dustinweber.com
- Javascript Includes: includes.dustinweber.com
- CSS: css.dustinweber.com
- Static Content: static.dustinweber.com
- Dynamic Content: dynamic.dustinweber.com

Now this is a pretty extreme example that I wouldn’t recommend for production (except in very specific cases), but let me explain what happens in simple terms. Instead of your browser making a request to one domain for all the content, data, files, and everything for a page; it splits up the requests amongst the various sub domains (of which could be hosted separately or together).

What does splitting up the content get us?

The advantage is that the browser isn’t sitting around waiting on previous requests to complete before moving on to the next item. It really only makes sense for larger pages. In fact there is a drawback, according to Aaron, “Beware that each additional hostname adds the overhead of an extra DNS lookup and an extra TCP three-way handshake. If your users have pipelining enabled or a given page loads fewer than around a dozen objects, they will see no benefit from the increased concurrency and the site may actually load more slowly. The benefits only become apparent on pages with larger numbers of objects. Be sure to measure the difference seen by your users if you implement this.”

Perhaps now you can consider playing around with this idea a bit on your own. Given plenty of tinkering time and careful examination, it could help decrease page load times noticeably.

If you’d like some more tips on this subject, check out Optimizing Page Load Time.

9 Responses to “Optimizing Page Load Time: Fixing Your HTTP Pipeline Problem”

  1. Anonymous Says:

    Nice picture! Now that is funny.

  2. Dustin Weber Says:

    If you say it’s funny, I’ll agree… but I don’t get it in this case.
    Why’s it funny? It’s just a ‘pipeline’.. right?
    - Dustin Weber

  3. Jeremy Says:

    I have windows xp pro. I cannot create subdomains. If I were to create a simple “get” webserver, that acts as an addition to iis (which calls index.html), and have each instance of this simple-server listening on different ports, eg . one instance for images eg. http://xxx.xxx.xxx.xxx:8088/image1.gif … etc., will I be able to achieve fake http pipelining?

    If this is not the case, than how would a be able to create a tcp listener (webserver), where I will be able to assign different sub.domains to my ip address, for each instance?

    -Jer A

  4. Dustin Weber Says:

    @Jeremy

    Well, you could try what you are talking about, but I’m not honestly sure that the port changes will make pipelining work like we need to. I know for a fact that alternate subdomains do though.. because I’ve tried it.

    I hate to tell you this, but you should probably consider switching to Apache on Windows (or preferably Linux) for solving a lot of the problem that IIS has (especially on Windows XP Pro). You can use Virtual Hosts to achieve what you are trying to do very easily (http://lifehacker.com/software/ask-lifehacker/ask-lifehacker-multiple-subdomains-147913.php).

    It’s honestly not very difficult to get the hang of Apache and you’ll suddenly realize a huge plethora of easy-to-use and easy-to-implement functionality that weren’t options in IIS (such as .htaccess files, virtual hosts, and mod-rewrite functionality just to name a few).

    Point is, you can set up all the virtual hosts (subdomains) you want in Apache quickly and easily.

    Hope that helps!

    - Dustin Weber

  5. Jeremy Says:

    Thank you for replying Dustin.

    Apache is not an option at this point.

    Considering the idea of different ports for achieving fake pipelining,
    How will I be able to test to see if there *really* is a difference, like you tested with sub-domains. What did you do?

    Also I’d like to compare my results on port changing with your results on sub-domains.

    -Jer A

  6. Dustin Weber Says:

    @ Jeremy

    I’d suggest the Firebug plug-in for Firefox. Go to the “Net” tab and it will show you details on page load times (per item)… and total load times. It’ll give you a good idea on what is going on (it’s even somewhat graphical).

    The only production set-up I’ve done with fake pipelining was a site that had a significant number of small images (a thumbnail gallery-type site). I split up all the different categories of images into different sub-domains and it really did pay off in overall page load time.

    Just remember that the advantage is only shown if there are a LOT of elements on a page. Otherwise, the extra NS lookups and TCP hand-shakes make it a bad idea.

    - Dustin Weber

  7. nnf Says:

    Hello,
    We are trying to implement pipeline in our web site. How can we do it with Apache? We have an application that generate relative path to our resources(images, css, js). Can Apache implement pipelining or we should try to modify our application?
    Thanks in advanced!!

  8. Hillary Cutrell Says:

    Lots of of bloggers aren’t very happy with this new iPad.There was too much hype over it and lots of people got turned off.You see, I actually see great deal of the awesome potential of the device. Third-party applications for making music, games, newspapers and magazines and FFS books, all sorts of good stuff, but IMHO they failed to sell it very well (excluding the books). It smells sort of unfinished

  9. Adam Says:

    Great post, Thanks,
    You can test pipeline using this free HTTP pipeline tool and test the response return from the web when sending different HTTP Get or post with pipeline:
    http://soft-net.net/SendHTTPTool.aspx

Leave a Reply