Since upgrading to Mac OS X Lion (from Snow Leopard), I have noticed that resolving to a virtual host is very slow (between about 3 seconds). I have found a number of tips (e.g., not using the .local TLD) that might resolve this, but they do not apply to my setup.
My setup is quite simple:
– Apache 2 (shipped with Lion)
– enabled PHP
– added a few virtual hosts
– installed Mail and SMTP Pear packages
Apache's hosts file looks like this:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 tbi.dev
127.0.0.1 www.tbi.dev
127.0.0.1 test1.tbi.dev
127.0.0.1 test2.tbi.dev
127.0.0.1 psa.dev
127.0.0.1 snd.dev
And Apache's virtual hosts file looks like this:
<VirtualHost *:80>
DocumentRoot "/Users/Bart/Sites/tbi"
ServerName tbi.dev
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/Bart/Sites/tbi"
ServerName tbi.dev
ServerAlias *.tbi.dev www.tbi.dev
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/Bart/Sites/psa"
ServerName psa.dev
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/Bart/Sites/sandbox"
ServerName snd.dev
</VirtualHost>
The setup is basically identical to my setup on Snow Leopard, but Apache's performance for resolving virtual hosts is significantly different. I run Mac OS X Lion 10.7.2, but the issue was already present when running 10.7.1.
This might seem like a small issue, but when you're accessing a virtual hosts a few hundreds of times a day then this adds up to a significant waste of time as you can imagine.
Best Answer
Long DNS timeouts are almost always a sign of IPv6 issues.
Do you need IPv6 connectivity to apache ?
If not, I suggest changing
into
Or disable IPv6 connectivity altogether.