Skip navigation

Firefox 2 + XHR + Persistent Connections = Fail

Persistent connections are great. They save a lot of packets on the network, and they save lots of latency.

Without persistent connections, you have to do a set up and tear down with every request. Persistent connections means that you can open a connection ONCE, then proceed to make multiple requests–as many as you like. After a few minutes of inactivity, your browser will go ahead and close the connection. With a good server, you’re in business.

Firefox persistent connections

Look at the network savings: If you do 10 of these requests persistent connections cuts the number of packets sent in half.

Persistent:
3 packets set up +

40 packets request/response +

4 packets teardown = 47 packets

VS

Stupid:
30 packets of set up +

40 packets of request/response +

40 packets teardown = 110 packets

Shorty got low low low low low low low

Even if you don’t care about packets, think about speed. All the bandwidth in the world doesn’t help you overcome per-request latency. And closing connections guarantees you an extra 50-100ms access time for each request. Boo.

But our good friend Firefox has a bug with persistent connections and XML-HTTP-REQUESTS. Namely, if you make more than a few XHR requests to a server with persistent connections, the requests it is supposed to be making don’t even go out the door. You click, nothing happens. Boo.

When I made 60 mil, Dre got paid

This was a really irritating bug in our UI, now fixed at the expense of more packets and more user latency. We’ve been forced to close connections for XHR requests to work around the bug in FF 2.

I’m popped up twice, ain’t trippin’ on nothin’

Yeah, yeah, yeah, HTTP is a stateless protocol. But my complaint is how FF’s HTTP implementation is interacting with TCP, which explicitly allows for persistence. Why do people mistakenly try to defend it? Why punish the network with twice as many packets and hurt the users with 50-100ms extra set up time? Persistence is the everyone’s friend. Let’s all do our best to support it wherever we can.

And let’s add real support for HTTP pipelining, while we’re at it. It’s another huge win that most browsers don’t get right.

Advertisements

Post a Comment

You must be logged in to post a comment.
%d bloggers like this: