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

In a very high loaded Ubuntu/PHP web server I found that the PHP line:


sometimes takes ~5 secs.

Replacing the url with the ip address decreases the server load from ~20 to 0

My question is - where are the settings that effect the DNS caching for this? Is it in the server level or the memcache library ? How can I change it ?

Additional info: Ubuntu 10.04 lucid PHP: 5.3.2-1ubuntu4.10 Apache/2.2.14 (Ubuntu) Amazon EC2

Even more info per Celada's comment:

The DNS handling for the memcache server is done by scalr (the platform I use to manage the cloud resources). They have a client located on the instances and their own DNS servers.

/etc/nsswitch.conf - hosts: files dns /etc/resolv.conf: nameserver domain ec2.internal search ec2.internal

The domain is not in hosts.conf To check if I run nscd I used /etc/init.d/nscd stop and received 'no such file' so i guess I dont run nscd.

Thanks !

share|improve this question
What are your hostname resolution settings ("hosts" line in /etc/nsswitch.conf and contents of /etc/resolv.conf)? Are you using a local DNS (e.g. in /etc/resolv.conf)? Does the hostname in question appear in /etc/hosts? Are you running nscd? By the way, the underscore character is not valid in host names. – Celada Mar 13 '12 at 22:14
Please see post edit – Niro Mar 14 '12 at 7:06
up vote 0 down vote accepted

I ended up doing double buffering of the ip addresses in APC (PHP Cache) memory. This solves all the DNS timing issues.

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.