Jan 4, 2010

Small performance enhancement tip

Do you have your own server? Does TYPO3 run slow? Would you like to try a simple step to improve the speed? Here it is.
Check if you have NSCD installed. NSCD is a caching daemon for DNS lookups. Even if you have HostnameLookups off in the Apache configuration, Apache still does look ups from time to time for internal reasons. If you do not have NSCD, it may take lots of seconds (especially if host does not exist). With properly configured NSCD it will be much faster.
Here is my NSCD configuration regarding DNS lookups:

enable-cache hosts yes
positive-time-to-live hosts 3600
negative-time-to-live hosts 60
suggested-size hosts 512
check-files hosts yes
This configuration means that NSCD will use caching for all DNS queries that applications on this system make. Note that applications do not have to be aware of NSCD. It is all automatic!
NSCD will cache resolved names for an hour and unresolved names for a minute. You can play with these parameters but do not increase time outs too much or NSCD will become a memory hog. I also set NSCD to check /etc/hosts file first. It is always faster than querying external DNS servers over network and you may want to put some of your hosts to that file.
In overal TYPO3 is much faster now, especially the Backend.
Happy caching! :)

3 comments:

  1. Hi Dmitry

    It sounds a bit like a workaround for your problem with Apache. Not that it is a bad workaround but still.. I guess Apache should not be resolving names "for internal reasons". Probably it is related to the security modules (You blogged about previously) doing additional checks or the applicationcode (eg PHP) doing something with lookups?

    ReplyDelete
  2. No, I do not have any such lookups in Apache (mod_security) or PHP at the moment. But strace shows that DNS lookups still happen in Apache. I do not know why.

    ReplyDelete
  3. Hello Dmitry,

    I learn a lot reading your tips ...
    One small thing here:
    parameter suggested-size should be a prime number, see inside the /etc/nscd.conf

    Regards
    Martin

    ReplyDelete