Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I manage a Ubuntu 10.04 server with a couple of domains hosted on it. As I continue to learn more about all these wonderful new (for me) technologies, one issue that I have begun to notice is the delay it sometimes takes for the server to respond to certain requests.

As an example, when I view the timeline of events using firebug I can see that most of the time when I make a POST, the server responds in under 100ms. Sometimes, however, there is a substantial delay before the RESPONSE from the server. I can't seem to tell when the delay will happen and when it won't, however, when it happens the delay is always for about 4.5 seconds. The delay seems to happen about 30-40% of the time.

Here is the section of apache2.conf dealing with logs:

#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
# If you are behind a reverse proxy, you might want to change %h into %{X-Forwarded-For}i
#
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

I have no idea where to look to try and debug this problem or investigate further.

Any suggestions?

share|improve this question

1 Answer 1

In my experience, weird delays like this are almost always related to reverse DNS lookups. These can take place in a few different configuration locations, but the most likely reverse DNS lookups are in Apache access and error logs. Check your Apache configuration for the formatting of log entries.

If you see something like %h anywhere in a log directive, it means that Apache is trying to log the host (DNS name) of the connecting client. Since most users and services will not have reverse DNS entries in place, you should remove the %h portion of the log directive. You can replace it with %a, which will log the IP instead.

share|improve this answer
    
Thanks for the quick suggestion Joel. I made the change you suggested and change all references to %h to %i and then restarted apache. Then I started doing a few tests and thought the problem was completely solved because I was not seeing the delay at all, but then suddenly it did begin to appear again. The delay seems to occur a bit less often, as far as I can tell at this early stage, but the delay still does happen sometimes. Having said that, I should add that the AJAX requests I am sending involve a query against a table with 4 million records, so maybe that is an issue. –  DanielAttard Oct 16 '12 at 5:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.