Postfix Performance Tuning – Reducing DNS latency

Making small changes to how we resolve domain names can make improve the Postfix performance and will allow you to squeeze a little more juice out of your hosts.

Removing IPv6 Queries

By default a postfix server works both with IPv6 and IPv4.
This means that if a domain name, lets say gmail, resolves to an IPv6 address, Postfix will try to connect to that address.
Now think of the overhead here. First we run a DNS query for gmail and get an IPv6 address, then we try to connect, fail and switch to IPv4.
Now that is a waste of resources.
So unless you are working with IPv6, disable it (for now).
To do so, edit the main.cf file at:
inet_protocols = all
And change it to:
inet_protocols = ipv4
* All lower-case
Now reload your postfix configuration:
service postfix reload

Local DNS Caching

When it comes to higher volumes of email, the Postfix documentation recommends installing a local DNS server. Running a local server will provide caching and thus allowing faster DNS response.

This is one example of how to install the Bind DNS server with minimum effort and configuration.

  • Use your favourite package manager to install the package. Im using yum in this example:
    yum install bind
  • Set Bind to start on boot:
    chkconfig named on 2,3,4
  • Edit the file /etc/named.conf
    And to the options section add the forwarders configuration:
    forwarders {
    8.8.8.8;
    };

    In this example I used google’s DNS servers (8.8.8.8). You can change it to your current servers.
  • Start the Bind service:
    service named start
  • The last step will be to direct the server’s DNS request to Bind.
    Edit the file /etc/resolve.conf
    And change the nameserver address to 127.0.0.1

If you have multiple servers, you may want to install a dedicated DNS server. Its better than managing a local server on each one, but it does mean having another box to worry about.

As you can see, these are small changes that can make a lot of difference when sending high volumes of email.

I will try to compile more configuration hacks that improves the Postfix performance so stay tuned.

, , , , , , , , , , , , , , , , , , ,

  • Mind Zuka

    must be /etc/resolv.conf not /etc/resolve.conf

Join my Online Postfix Class
Join my Online Postfix Class
I am working on a new Postfix training class that will be launching soon. The course includes:
  • Understanding the Logs files
  • Troubleshooting
  • Performance
  • Rate limiting
  • DKIM/DMARC/SPF
  • And much More

Powered by WordPress. Designed by Woo Themes