在 Debian 上提升邮件服务器(如 Postfix / Exim / Dovecot 等)的速度,通常可以从系统层、邮件服务配置、网络与 DNS、存储与队列、反垃圾策略几个方面入手。下面以 Postfix + Dovecot(最常见组合) 为例说明。
邮件服务器 I/O 密集:
/var/spool/postfix)/var/mail 或 Dovecot 的 mail_location)建议:
mount | grep spool
将队列和邮箱放在 SSD 上。
推荐:
ext4 或 xfsdefaults,noatime,nodiratime
ulimit -n
编辑:
/etc/security/limits.conf
* soft nofile 65535
* hard nofile 65535
Postfix:
postconf -e "default_process_limit = 100"
postconf -e "process_limit = 100"
postconf -e "smtp_process_limit = 50"
postconf -e "qmgr_message_recipient_limit = 20000"
postconf -e "queue_run_delay = 60s"
postconf -e "minimal_backoff_time = 60s"
postconf -e "maximal_backoff_time = 1h"
如不使用:
postconf -e "smtpd_helo_required = no"
postconf -e "smtpd_sender_restrictions = "
⚠️ 生产环境需权衡安全
postconf -e "smtp_connection_cache_on_demand = yes"
postconf -e "smtp_connection_cache_time_limit = 300s"
邮件发送严重依赖 DNS。
apt install unbound
Postfix:
postconf -e "smtp_dns_resolver_timeout = 5s"
postconf -e "smtp_dns_support_level = dnssec"
mail_location = maildir:~/Maildir
maildir_very_dirty_syncs = yes
mmap_disable = no
mail_cache_min_mail_count = 10
service imap-login {
process_limit = 200
}
apt install rspamd
sysctl -w net.ipv4.tcp_tw_reuse=1
sysctl -w net.core.somaxconn=1024
mailq
postqueue -p
doveadm who
iotop
| 原因 | 解决 |
|---|---|
| DNS 慢 | 本地 DNS 缓存 |
| 磁盘慢 | SSD |
| SpamAssassin | 换 rspamd |
| 并发低 | 提高 process_limit |
| 队列堵塞 | 调整 backoff |
如果你能告诉我:
我可以给你一套针对性配置。