Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Any one having any ideas where should I start to fix this issue, the first handshake take sometimes up to 20s, but refreshes after that takes only 0.9s.

The setup,

100/10 Mbps
Windows OS
Intel Core 2 @ 3.0 GHz
And 7200 RPM HDD

Apache 2.4
Mod_Security Enabled
Mod_Deflate Enabled
Mod_Expires Enabled
Mod_ReWrite Enabled
PHP & MySQL on same machine.

I have seen much slower machines preforming better, therefor I think my problem is ony an optimization issue.

share|improve this question
Couple of questions: Is it a production machine? Is it under load? Have you tried to look at the output of mod_status? How are you performing these tests? Using ab (apache benchmark) are you able to replicate the problem and get some specific metrics? – Khai Jun 18 '12 at 1:50
The server isn't under load, it runs a very lightweight client management system with up to 300 connections at the same time. I'll check the status mod. – Johan Larsson Jun 18 '12 at 2:32
300 connections could be a lot. Do you mean 300 simultaneously TCP connections that are sending or receiving traffic most of the time? – Mircea Vutcovici Jun 18 '12 at 2:41
Not always, but yes it gets up to 300 TCP connections. (Many users are working on the system at the same time). – Johan Larsson Jun 18 '12 at 2:45
up vote 1 down vote accepted

It seems that you have activated DNS resolving inside apache. This allow you to have hostnames instead of IPs in your apache logs.

If it is not the case, then best way to test is to analyze the network traffic. This can be done with:

  • a network sniffer like WireShark
  • a HTTP proxy/analyzer like Fiddler2
  • a browser plugin like FireBug

You can also start the investigation by running:

curl --trace-time -vI

Where is your site. Please add this output to your question.

share|improve this answer
I've already tested Firebug, For the first connection that takes 10s, 9.5s is used to resolve the domain and get the initial respons. 0.5s for recieving page conent. So the content is well optimized. – Johan Larsson Jun 18 '12 at 2:51
Than you have a DNS issue. Check if your first DNS server is reachable. – Mircea Vutcovici Jun 18 '12 at 2:53
To rule out that your DNS is, or is not the problem, addd an entry into etc/hosts file with your server_IP followed by your server FQDN. – Mircea Vutcovici Jun 18 '12 at 2:55
What is the output of: nslookup -q=any – Mircea Vutcovici Jun 18 '12 at 2:59
If you use WireShark, you will be able to see that the first DNS request will time out. – Mircea Vutcovici Jun 18 '12 at 3:00

Starting in Windows 6.1 (Server 2008 R2 and Windows 7), Windows has stopped using the hosts file to resolve localhost and now uses it's own DNS resolver which is slow.

Two ways to fix this:

a) You can find and replace every instance of "localhost" to "" in your web applications (database connections), httpd.conf, httpd-vhosts.conf, php.ini and anywhere else you can think of.


b) In the file hosts located here: "C:\Windows\System32\Drivers\etc"

Uncomment the last two lines.

# localhost name resolution is handled within DNS itself.
#       localhost
#   ::1             localhost
share|improve this answer

This specific problem was caused by mod_bw whitch I'm using on the server to limit traffic usage. It was limiting for all files and caused even the HTML files to get some delay. After configuring this correctly, everything is working just fine.

share|improve this answer

Your Answer


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.