luntain
luntain

Reputation: 4680

What is causing over 200ms wait for an http response?

Firebug shows not only the time it takes for individual requests, but splits them into phases. Most of the time spent on getting small files (~20KB) is spent waiting for the response (at least according to Firebug).

On stackoverflow, for instance, the wait for response on / takes 255 ms, transfer 42ms. On other sites I have seen figures like: 200ms response wait and 1 ms transfer. What is causing the wait?

Web sites are usually comprised from many files: the html document, css, js, some images. Take any of the demos here, dojox gfx demos, most of the time is spent in between transfering the tiny js files. This whole model strikes me as very inefficient.

Upvotes: 4

Views: 3706

Answers (5)

Nelson
Nelson

Reputation: 29706

200ms reminds me of Nagle's algorithm. Briefly stated, many operating systems will delay sending the first TCP packet for 200ms to see if any more data needs to be sent. I don't know for certain that it applies in the modern web context. An HTTP request is small enough that it might be delayed by nagling, but you'd hope the OS would be smart enough or at least the browser would disable naglging on requests.

If you run a packet sniffer and examine the trace's timestamps you can work out exactly where the 200ms is going.

Upvotes: 1

vorushin
vorushin

Reputation: 586

Waiting time is caused by processing your request on server-side (browsing through the questions database, creating of result page etc.) plus network delay (ping time)

Upvotes: 2

David
David

Reputation: 3227

Before you receive the response, the following things have to happen:

  1. Your packet traverses the wild internets to the server.
  2. The server has to process the request and figure out what web site, virtual directory, whatever it belongs to.
  3. The web server has to pull the file off the disk. If it's a dynamic file it has to run it through the interpreter/execution engine/whatever (often the file must be completely processed before the server even begins to respond).
  4. The server has to begin the response and that packet has to traverse the intertrons back to the client.

If you figure 50ms as a ping time, a 200ms response time leaves 150ms for the server to do all its stuff...not blindingly fast, but respectable.

Upvotes: 4

VoteyDisciple
VoteyDisciple

Reputation: 37803

Just the network "lag" (to abuse the term) — the time you'd see in a ping — is probably around 50 - 100 ms, plus it will take the server a certain amount of time to parse the request, retrieve the file from disk, log the request, possibly read from a database, et cetera.

The short answer is: it takes time for servers to do stuff.

Upvotes: 1

dfa
dfa

Reputation: 116314

DNS resolution? try change your DNS, then repeat the test

Upvotes: 0

Related Questions