Emil CHERICHES

Emil CHERICHES

TIP: Make Postfix use less SQL connections

August 9, 2013 Emil C
No Comments

When you manage Postfix mail servers using SQL connections to find informations about usernames, mailbox/maildir locations on the disk you probably have in your main.cf something like :

virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
relay_domains = mysql:/etc/postfix/mysql_relay_domains_maps.cf

But, this way, each process(postfix process) uses one MySQL connection. Each mail that relays thru your server will open and close a MySQL connection. This is probably working on a simple mail server that handles 3 domain names and around 15 normal mailboxes, but when you have thousands of mail per hour that pass thru your mail server this could mean lots and lots of useless load to your server.

A simple way to make Postfix use less connections is to just put “proxy:”  in front of all “mysql:” statements in main.cf. You will have:

virtual_alias_maps = proxy:mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
relay_domains = proxy:mysql:/etc/postfix/mysql_relay_domains_maps.cf

This way, Postfix routes all SQL queries thru one of the two of it’s daemons called proxymap(used to fetch informations from the database) and proxywrite(used to write informations in the database).

Tips & Tricks MySQLPostfix
Previous Post

Why caching is good

Next Post

TIP: Debian/Ubuntu prevent accidental halts/reboots

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • Flash Tasmota on the Sonoff Mini – Linux user experience
  • DokuWiki a simple solution to sorting documentation
  • I discovered Wireguard
  • Using Let’s Encrypt with CentOS (for now)
  • Let’s Encrypt is Trusted

Categories

  • from the web
  • just blog
  • linux
    • Mail Server Series
  • News
  • phones
  • Phones & Tablets
  • programing
  • security
  • Smart Home
  • Tips & Tricks
  • Uncategorized
  • Web development
  • Windows

Blogroll

  • cheriches.fr
Subscribe by Email

Recent Posts

  • Flash Tasmota on the Sonoff Mini – Linux user experience
  • DokuWiki a simple solution to sorting documentation
  • I discovered Wireguard
  • Using Let’s Encrypt with CentOS (for now)
  • Let’s Encrypt is Trusted

Categories

  • from the web (3)
  • just blog (1)
  • linux (23)
    • Mail Server Series (7)
  • News (1)
  • phones (1)
  • Phones & Tablets (2)
  • programing (1)
  • security (2)
  • Smart Home (1)
  • Tips & Tricks (15)
  • Uncategorized (3)
  • Web development (1)
  • Windows (1)

Blogroll

  • cheriches.fr

Tags cloud

12.04 aircrack-ng Android Apache apt-get backports BlackBerry cache CentOS Chrome CSS CyanogenMod debian Dell dotdeb Dovecot Eee PC Firefox FPM GNOME Hardware internet explorer javascript KVM linux MariaDB MPM MySQL Nginx OpenVPN php piwik Postfix Postfix Admin RedHat release RHEL Samba SELinux smarty ubuntu wifi windows xp Youtube

Recent Comments

  • Frank on Dedicated Mail Server Hosting Multiple Domains – Step 3 – Postfix and Dovecot
  • Andrew Schott on Dedicated Mail Server Hosting Multiple Domains – Step 3 – Postfix and Dovecot
  • Emil C on Dedicated Mail Server Hosting Multiple Domains – Step 3 – Postfix and Dovecot
  • Andrew Schott on Dedicated Mail Server Hosting Multiple Domains – Step 3 – Postfix and Dovecot
  • Emil C on Dedicated Mail Server Hosting Multiple Domains – Step 3 – Postfix and Dovecot
Proudly powered by WordPress | Theme: Fmi by Forrss.