Qmail:第一封邮件很慢(1-2 秒),后续邮件越来越慢(4-60 秒)

Qmail:第一封邮件很慢(1-2 秒),后续邮件越来越慢(4-60 秒)

我的 vServer 比较旧(Plesk 8.6、openSUSE 10.3、Qmail)。几个月后就会被替换,但在此之前我需要一个解决方案。

大约两个月后,发送电子邮件的速度会变慢。如果您想使用电子邮件客户端发送电子邮件,有时必须等待一分钟或更长时间。同一台服务器上有一个 Web 应用程序,它每天通过 PHP 函数 mail() 发送约 1000 封(处理)电子邮件。

Plesk 经常显示 smtp 服务未运行。但 qmail-send 进程正在运行,并且邮件队列中的邮件已发送(缓慢)。qmail-send 进程占用的资源不多,top 显示负载在 0.4 到 2 之间。

但是发送的其他邮件之间存在相关性。如果 qmail 在邮件队列(本地或远程)中有其他邮件,速度就会下降。如果邮件队列为空,PHP mail() 大约需要一秒钟,当邮件队列中有更多邮件时,邮件需要 10-60 秒。如果我调用 php 脚本两次,第一封邮件将发送得很快,第二封邮件将发送得慢得多。

在邮件流量大的时候,延迟会增加。邮件是从 webapp 还是从外部邮件客户端创建的并不重要。

我检查了名称服务器、反向 DNS 以及 qmail 是否会使用 -Rt0 参数启动。不涉及证书。一些邮箱有 6 GB 大。

我没有更改 qmail 的并发设置,因为即使邮件队列中只有一封邮件也会出现问题。而且第一封邮件也很慢,需要一秒钟。

/var/qmail/handlers/spool 中有大约 200 封旧邮件。

有人知道出了什么问题吗?

使用 PHP 测试:

$ php mail.php
Sending mail()
0.63656902313232 seconds
$ php mail.php
Sending mail()
4.7495679855347 seconds

使用 qmail-inject 构建/测试:

h14xxxxx:~ # date; echo to: [email protected] | /var/qmail/bin/qmail-inject; date
Do 16. Feb 13:24:24 CET 2012
Do 16. Feb 13:24:25 CET 2012
h14xxxxx:~ # date; echo to: [email protected] | /var/qmail/bin/qmail-inject; date
Do 16. Feb 13:24:26 CET 2012
Do 16. Feb 13:24:28 CET 2012
h14xxxxx:~ # date; echo to: [email protected] | /var/qmail/bin/qmail-inject; date
Do 16. Feb 13:24:29 CET 2012
Do 16. Feb 13:24:34 CET 2012
h14xxxxx:~ # date; echo to: [email protected] | /var/qmail/bin/qmail-inject; date
Do 16. Feb 13:24:35 CET 2012
Do 16. Feb 13:24:39 CET 2012
h14xxxxx:~ #

通过 /usr/local/psa/var/log/maillog 访问

Feb 16 13:24:24 h14xxxxx qmail-queue-handlers[19931]: Handlers Filter before-queue for qmail started ...
Feb 16 13:24:24 h14xxxxx qmail-queue-handlers[19931]: [email protected]
Feb 16 13:24:24 h14xxxxx qmail-queue-handlers[19931]: [email protected]
Feb 16 13:24:24 h14xxxxx qmail-queue-handlers[19931]: hook_dir = '/var/qmail//handlers/before-queue'
Feb 16 13:24:24 h14xxxxx qmail-queue-handlers[19931]: recipient[3] = '[email protected]'
Feb 16 13:24:24 h14xxxxx qmail-queue-handlers[19931]: handlers dir = '/var/qmail//handlers/before-queue/recipient/[email protected]'
Feb 16 13:24:25 h14xxxxx qmail-queue-handlers[19931]: starter: submitter[19932] exited normally
Feb 16 13:24:25 h14xxxxx qmail: 1329395065.157427 new msg 9850236
Feb 16 13:24:25 h14xxxxx qmail: 1329395065.157626 info msg 9850236: bytes 230 from <[email protected]> qp 19932 uid 0
Feb 16 13:24:25 h14xxxxx qmail: 1329395065.856861 starting delivery 46: msg 9850236 to local [email protected]
Feb 16 13:24:25 h14xxxxx qmail: 1329395065.857024 status: local 1/10 remote 0/20
Feb 16 13:24:25 h14xxxxx qmail-local-handlers[19934]: Handlers Filter before-local for qmail started ...
Feb 16 13:24:26 h14xxxxx qmail-queue-handlers[19938]: Handlers Filter before-queue for qmail started ...
Feb 16 13:24:26 h14xxxxx qmail-local-handlers[19934]: [email protected]
Feb 16 13:24:26 h14xxxxx qmail-local-handlers[19934]: [email protected]
Feb 16 13:24:26 h14xxxxx qmail-queue-handlers[19938]: [email protected]
Feb 16 13:24:26 h14xxxxx qmail: 1329395066.298940 delivery 46: success: did_0+0+2/
Feb 16 13:24:26 h14xxxxx qmail-queue-handlers[19938]: [email protected]
Feb 16 13:24:27 h14xxxxx qmail-queue-handlers[19938]: hook_dir = '/var/qmail//handlers/before-queue'
Feb 16 13:24:27 h14xxxxx qmail: 1329395067.091093 status: local 0/10 remote 0/20
Feb 16 13:24:28 h14xxxxx qmail-queue-handlers[19938]: recipient[3] = '[email protected]'
Feb 16 13:24:28 h14xxxxx qmail: 1329395068.363638 end msg 9850236
Feb 16 13:24:28 h14xxxxx qmail-queue-handlers[19938]: handlers dir = '/var/qmail//handlers/before-queue/recipient/[email protected]'
Feb 16 13:24:28 h14xxxxx qmail-queue-handlers[19938]: starter: submitter[19942] exited normally
Feb 16 13:24:28 h14xxxxx qmail: 1329395068.665296 new msg 9850184
Feb 16 13:24:28 h14xxxxx qmail-local-handlers[19944]: Handlers Filter before-local for qmail started ...
Feb 16 13:24:29 h14xxxxx qmail: 1329395069.473648 info msg 9850184: bytes 230 from <[email protected]> qp 19942 uid 0
Feb 16 13:24:29 h14xxxxx qmail-queue-handlers[19948]: Handlers Filter before-queue for qmail started ...
Feb 16 13:24:29 h14xxxxx qmail-local-handlers[19944]: [email protected]
Feb 16 13:24:30 h14xxxxx qmail: 1329395070.264613 starting delivery 47: msg 9850184 to local [email protected]
Feb 16 13:24:30 h14xxxxx qmail-local-handlers[19944]: [email protected]
Feb 16 13:24:30 h14xxxxx qmail-queue-handlers[19948]: [email protected]
Feb 16 13:24:31 h14xxxxx qmail: 1329395071.364589 status: local 1/10 remote 0/20
Feb 16 13:24:32 h14xxxxx qmail-queue-handlers[19948]: [email protected]
Feb 16 13:24:32 h14xxxxx qmail: 1329395072.423865 delivery 47: success: did_0+0+2/
Feb 16 13:24:32 h14xxxxx qmail-queue-handlers[19948]: hook_dir = '/var/qmail//handlers/before-queue'
Feb 16 13:24:33 h14xxxxx qmail: 1329395073.026831 status: local 0/10 remote 0/20
Feb 16 13:24:33 h14xxxxx qmail-queue-handlers[19948]: recipient[3] = '[email protected]'
Feb 16 13:24:33 h14xxxxx qmail: 1329395073.401616 end msg 9850184
Feb 16 13:24:33 h14xxxxx qmail-queue-handlers[19948]: handlers dir = '/var/qmail//handlers/before-queue/recipient/[email protected]'
Feb 16 13:24:34 h14xxxxx qmail-queue-handlers[19948]: starter: submitter[19952] exited normally
Feb 16 13:24:34 h14xxxxx qmail: 1329395074.558677 new msg 9850184
Feb 16 13:24:34 h14xxxxx qmail: 1329395074.773783 info msg 9850184: bytes 230 from <[email protected]> qp 19952 uid 0
Feb 16 13:24:34 h14xxxxx qmail-local-handlers[19954]: Handlers Filter before-local for qmail started ...
Feb 16 13:24:35 h14xxxxx qmail: 1329395075.309948 starting delivery 48: msg 9850184 to local [email protected]
Feb 16 13:24:35 h14xxxxx qmail-queue-handlers[19958]: Handlers Filter before-queue for qmail started ...
Feb 16 13:24:36 h14xxxxx qmail: 1329395076.330075 status: local 1/10 remote 0/20
Feb 16 13:24:36 h14xxxxx qmail-local-handlers[19954]: [email protected]
Feb 16 13:24:37 h14xxxxx qmail-local-handlers[19954]: [email protected]
Feb 16 13:24:37 h14xxxxx qmail-queue-handlers[19958]: [email protected]
Feb 16 13:24:37 h14xxxxx qmail: 1329395077.678698 delivery 48: success: did_0+0+2/
Feb 16 13:24:38 h14xxxxx qmail-queue-handlers[19958]: [email protected]
Feb 16 13:24:38 h14xxxxx qmail: 1329395078.009558 status: local 0/10 remote 0/20
Feb 16 13:24:38 h14xxxxx qmail: 1329395078.871718 end msg 9850184
Feb 16 13:24:38 h14xxxxx qmail-queue-handlers[19958]: hook_dir = '/var/qmail//handlers/before-queue'
Feb 16 13:24:38 h14xxxxx qmail-queue-handlers[19958]: recipient[3] = '[email protected]'
Feb 16 13:24:39 h14xxxxx qmail-queue-handlers[19958]: handlers dir = '/var/qmail//handlers/before-queue/recipient/[email protected]'
Feb 16 13:24:39 h14xxxxx qmail: 1329395079.587290 new msg 9850184
Feb 16 13:24:39 h14xxxxx qmail-queue-handlers[19958]: starter: submitter[19962] exited normally
Feb 16 13:24:39 h14xxxxx qmail: 1329395079.697880 info msg 9850184: bytes 230 from <[email protected]> qp 19962 uid 0
Feb 16 13:24:40 h14xxxxx qmail-local-handlers[19964]: Handlers Filter before-local for qmail started ...
Feb 16 13:24:40 h14xxxxx qmail: 1329395080.167264 starting delivery 49: msg 9850184 to local [email protected]
Feb 16 13:24:41 h14xxxxx qmail: 1329395081.380693 status: local 1/10 remote 0/20
Feb 16 13:24:40 h14xxxxx qmail-local-handlers[19964]: [email protected]
Feb 16 13:24:41 h14xxxxx qmail-local-handlers[19964]: [email protected]
Feb 16 13:24:41 h14xxxxx qmail: 1329395081.775765 delivery 49: success: did_0+0+2/
Feb 16 13:24:41 h14xxxxx qmail: 1329395081.775847 status: local 0/10 remote 0/20
Feb 16 13:24:41 h14xxxxx qmail: 1329395081.904212 

/etc/resolv.conf

nameserver 85.214.7.22
nameserver 81.169.163.106

/etc/hosts

127.0.0.1       localhost

# special IPv6 addresses
::1             localhost ipv6-localhost ipv6-loopback

fe00::0         ipv6-localnet

ff00::0         ipv6-mcastprefix
ff02::1         ipv6-allnodes
ff02::2         ipv6-allrouters
ff02::3         ipv6-allhosts

# Auto-generated hostname. Please do not remove this comment.
85.214.xx.xxx h14xxxxx.stratoserver.net h14xxxxx

$nslookup 127.0.0.1

Server:         85.214.7.22
Address:        85.214.7.22#53

Non-authoritative answer:
1.0.0.127.in-addr.arpa  name = localhost.

Authoritative answers can be found from:

$nslookup 85.214.xx.xxx

Server:         85.214.7.22
Address:        85.214.7.22#53

Non-authoritative answer:
163.96.214.85.in-addr.arpa      name = h14xxxxx.stratoserver.net.

Authoritative answers can be found from:

/var/qmail/control/我

h14xxxxx.stratoserver.net

/var/qmail/control/本地

localhost

/etc/xinet.d/smtp_psa

service smtp
{
        socket_type     = stream
        protocol        = tcp
        wait            = no
        disable         = no
        user            = root
        instances       = UNLIMITED
        env             =  SMTPAUTH=1
        server          = /var/qmail/bin/tcp-env
        server_args     = -Rt0  /var/qmail/bin/relaylock /var/qmail/bin/qmail-smtpd /var/qmail/bin/smtp_auth /var/qmail/bin/true /var/qmail/bin/cmd5checkpw /var/qmail/bin/true
}

/etc/xinet.d/smtps_psa

service smtps
{
        socket_type     = stream
        protocol        = tcp
        wait            = no
        disable         = no
        user            = root
        instances       = UNLIMITED
        env             =  SMTPAUTH=1
        server          = /var/qmail/bin/tcp-env
        server_args     = -Rt0  /var/qmail/bin/relaylock /var/qmail/bin/qmail-smtpd /var/qmail/bin/smtp_auth /var/qmail/bin/true /var/qmail/bin/cmd5checkpw /var/qmail/bin/true
}

顶部

top - 13:53:29 up 21:53,  2 users,  load average: 0.78, 0.58, 0.42
Tasks:  83 total,   3 running,  80 sleeping,   0 stopped,   0 zombie
Cpu(s):  5.4%us,  2.0%sy,  0.0%ni, 86.7%id,  6.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   6291456k total,   473208k used,  5818248k free,        0k buffers
Swap:        0k total,        0k used,        0k free,        0k cached

相关内容