1

I've noticed my web server takes a long time to load pages recently. Using Firebug, I realised it takes around 4s for the DNS lookup:

Connecting: 304ms
Sending: 0ms
Waiting: 3.45s
Receiving: 0ms

I thought that was a long time to wait for a HTTP response. In the command line, I initiated:

telnet localhost 80
GET / HTTP/1.1
Host: {IP Address}

And waited until these next three commands were returned before entering twice. The first command I used was to find out the port number:

lsof -p `pidof telnet`

Then, to find out the process:

netstat -nap | grep {port}

And finally:

strace -o /tmp/output -f -r -s4096 -p {PID}

I then pressed enter on the telnet command to return the request so that it would log in the output file. When the telnet finally returned I had a look at the output file and searched for the longest processes, which were:

6152      12.143817 read(17, "GET / HTTP/1.1\r\n", 8000) = 16
6152       0.000178 gettimeofday({1330023713, 143410}, NULL) = 0
6152       0.000169 poll([{fd=17, events=POLLIN}], 1, 60000) = 1 ([{fd=17, revents=POLLIN}])
6152      13.550608 read(17, "Host: 164.177.156.189\r\n", 8000) = 23

Does anybody know why these two processes are taking so long? Is it a DNS lookup issue? What should I do to address the problem?

hohner
  • 213
  • 2
  • 3
  • 7

1 Answers1

4

It took you 12 seconds to type "GET / HTTP/1.1\r\n" and 13 seconds to type "Host: 164.177.156.189\r\n". So the server spend that long reading them.

David Schwartz
  • 31,449
  • 2
  • 55
  • 84