Postfix MTA结合Cyrus搭建的SMTP服务器发送速度过慢求助
Hey there, sorry you've been stuck on this for days—5 seconds per email is definitely not normal for Postfix, especially when logs show no obvious errors. Let's walk through some likely culprits you might have missed:
1. Check Postfix Concurrency & Rate Limiting Settings
This is the most common fix for consistent slow sending. Postfix might be configured to send only one email at a time, or have a forced delay between deliveries.
- First, check your current concurrency limits with:
postconf | grep -E "(concurrency_limit|rate_delay)" - Look for parameters like
smtp_destination_concurrency_limit(defaults to 1 in some setups) anddefault_destination_concurrency_limit. If these are set to 1, Postfix will only send one email per destination at a time. Bump these up to a reasonable number (e.g., 10 or 20) inmain.cf:smtp_destination_concurrency_limit = 10 default_destination_concurrency_limit = 15 - Also check for
smtp_destination_rate_delayordefault_destination_rate_delay—if either is set to 5s, that's exactly your issue! Set them to 0 to disable the delay:smtp_destination_rate_delay = 0 default_destination_rate_delay = 0 - After making changes, restart Postfix with
systemctl restart postfix(orservice postfix restartdepending on your distro).
2. Verify DNS Resolution Speed
Even if logs don't show errors, slow DNS lookups for MX records can add per-email delays.
- Test MX record lookup speed for a destination domain:
If this takes more than a few hundred milliseconds, your DNS setup is slow. Try using a local DNS cache (like dnsmasq) or switch to a faster public DNS intime dig example.com MX/etc/resolv.conf.
3. Check for Content Filtering Bottlenecks
If you're using content filters like Amavis, SpamAssassin, or ClamAV, these can slow down email processing if they're under-resourced or misconfigured.
- Temporarily disable filtering by commenting out the
content_filterline inmain.cf, then restart Postfix. If sending speed improves, your filter is the bottleneck—check its logs (e.g.,/var/log/amavis.log) for delays, or increase its resource limits.
4. DKIM Signature Overhead
If you've enabled DKIM signing, using a large key (like 4096-bit) can add significant processing time per email.
- Check your DKIM key size in your DKIM configuration (usually in
/etc/opendkim/keys/). If it's 4096-bit, generate a 2048-bit key instead—this cuts signing time drastically while still being secure.
5. System Resource Constraints
Insufficient CPU, memory, or disk IO can throttle Postfix:
- Use
toporhtopto check if Postfix processes (e.g.,qmgr,smtp) are using excessive CPU or memory. - Use
iotoporiostatto check disk IO on the partition where Postfix stores its queues (usually/var/spool/postfix). High IO wait times mean the disk can't keep up with queue operations.
6. Cyrus Interaction (If Relevant)
Since you're using Cyrus, double-check if Postfix is routing outgoing emails through Cyrus unnecessarily. Outgoing emails should be handled directly by Postfix's SMTP component—verify your main.cf has relayhost set correctly (if you use a relay) and that local delivery is only for internal users.
After trying each step, monitor your sending speed—most of the time, adjusting concurrency or disabling an accidental rate delay fixes this issue. Good luck!
内容的提问来源于stack exchange,提问作者Jiteshp715

