Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of automatic adaptation configuration of Postfix pressure

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

这篇文章将为大家详细讲解有关Postfix压力自动适应配置的示例分析,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

postfix负载过高的标识(Symptoms of Postfix SMTP server overload)

客户端连接过来后需要等待一段时间才能得到服务器回应的欢迎信息:"220 hostname.example.com ESMTP Postfix"

服务器的日志里出现越来越多的类似日志:"lost connection after CONNECT", 一般这种情况是由于客户端因等待太久而断开了连接。

Postfix 2.3及以后的版本会在服务端口繁忙时输出一条警告日志,类似如下:

Oct 3 20:39:27 spike postfix/master[28905]: warning: service "smtp" (25) has reached its process limit "30": new clients may experience noticeable delaysOct 3 20:39:27 spike postfix/master[28905]: warning: to avoid this condition, increase the process count in master.cf or reduce the service time per clientOct 3 20:39:27 spike postfix/master[28905]: warning: see http://www.postfix.org/STRESS_README.html for examples of stress-adapting configuration settings

自动适应压力行为(Automatic stress-adaptive behavior)

当smtp服务器在面向"public"网络的所有端口都变繁忙时,postfix将记录一条warn日志,并使用参数"-o stress=yes" 重启服务。如果服务只有本地的连接则不会启用自动适应压力的行为。在main.cf中,stress参数专门用来配置自动适应压力的行为:

1 smtpd_timeout = ${stress?{10}:{300}}s2 smtpd_hard_error_limit = ${stress?{1}:{20}}3 smtpd_junk_command_limit = ${stress?{1}:{100}}4 # Parameters added after Postfix 2.6:5 smtpd_per_record_deadline = ${stress?{yes}:{no}}6 smtpd_starttls_timeout = ${stress?{10}:{300}}s7 address_verify_poll_count = ${stress?{1}:{3}}

stress后面第一个参数表示高负载时采用的参数值,第二个参数表示低负载时使用的参数。

同时为更多smtp客户端提供服务(Service more SMTP clients at the same time)

为了服务更多的客户端,可以提高smtp服务端进程的数量:通过修改main.cf的default_process_limit 或master.cf的maxproc参数:

1 /etc/postfix/main.cf: 2 # Raise the global process limit, 100 since Postfix 2.0. 3 default_process_limit = 200 4 5 /etc/postfix/master.cf: 6 # ============================================================= 7 # service type private unpriv chroot wakeup maxproc command 8 # ============================================================= 9 # Raise the SMTP service process limit only.10 smtp inet n - n - 200 smtpd

进程越多则消耗的内存越多,可以通过使用cdb查询表来代替hash,btree表来减小内存的使用。

提高对每个smtp客户端的处理速度(Spend less time per SMTP client)

如果提高服务端进程的数量不可行,可以想办法减少对每个smtp客户端的响应延迟:

消除对不可用的RBL服务的查询

消除对重复的RBL服务的查询(比如一个rbl包含了另一个rbl的情况,只需要查询包含的那个rbl即可)

消除header_checks和body_checks,只保留少数针对最新蠕虫的模式检查即可。

对header_checks和body_checks分组以减少不必要的模式匹配检查。

主动断开可疑客户端的连接(Disconnect suspicious SMTP clients)

在高负载时,主动断开可疑连接可以让其他客户端有连接进来的机会:

使用"521"响应码,可以让postfix主动拒绝邮件的发送并马上断开与客户端的连接,不需要等客户端发送quit指令。

怎么识别当前是否已经启用压力自动适应行为(Detecting support for stress-adaptive behavior)

使用"ps -ef"命令查看smtpd进程,如果进程启用了该模式,则会带有"-o stress=" 或 "-o stress=yes"选项。

强制开启或关闭压力自动适应行为(Forcing stress-adaptive behavior on or off)

在master.cf中配置"-o stress=yes"命令行选项可以强制开启该行为:

1 /etc/postfix/master.cf:2 # =============================================================3 # service type private unpriv chroot wakeup maxproc command4 # =============================================================5 # 6 smtp inet n - n - - smtpd7 -o stress=yes8 -o . . .

如果配置"-o stress="则表示永久关闭自动适应行为

关于"Postfix压力自动适应配置的示例分析"这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report