Chapter 20. Server Performance

While there are literally thousands of things you can do to help web performance, here are 10 areas that will provide large and quick performance improvement for your efforts.

Turn Off Reverse DNS Lookups

Reverse DNS maps IP numbers to machine names. The web server uses reverse DNS for two things: writing a machine name rather than simply an IP address in the web servers logs, and giving CGI programs easy access to the client machine name. The CGI program can access the client machine name via the REMOTE_HOST environment variable if reverse DNS is on.

The problems with reverse DNS are that it can take a long time and is generally implemented as a blocking system call. This means that the current process or thread can do no further work until the call either returns with an answer or times out. While the time required generally isn’t a problem for a single HTTP request, it rapidly becomes the server bottleneck if there are more than a few users making requests.

Fortunately, you don’t really need reverse DNS to be turned on in your web server. First of all, your CGI program may not even use the REMOTE_HOST environment variable. If the CGI does need to know the client DNS name, it can make the DNS call itself. And while it is more enlightening for a human to see DNS names rather than IP addresses in the server logs, server logs can be processed offline and the mapping of IP to DNS name done then.

Here is how your CGI can get machine names from IP numbers. ...

Get Webmaster in a Nutshell, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.