Apache2 针对大量轻量级连接的优化技巧
我们有一个用 PHP 编写的非常轻量级的跟踪脚本,在 Apache/2.2.14 (Ubuntu) 上运行。该脚本将接收大量并发连接,但每个连接都会很快。目前,我们正在使用 prefork,配置如下:
StartServers 5
MinSpareServers 5
MaxSpareServers 10
ServerLimit 600
MaxClients 600
MaxRequestsPerChild 0
我们还关闭了 KeepAlive
我已经对这些设置进行了相当多的尝试,并且已经使用 apache benchmark 进行了测试。每当我使用 ab 提高并发连接时,我都会收到“apr_socket_recv:连接由对等方重置 (104)”。我还提高了文件描述符的最大数量。
我想知道是否有任何 apache 专家可以为我指出这种类型设置的正确方向(大量轻量级连接)。 StartServers、Min/MaxSpareServers 等的最佳值是多少?工人 MPM 值得研究吗?欢迎任何想法。
We have a very lightweight tracking script written in PHP, running on Apache/2.2.14 (Ubuntu). The script will receive a high number of concurrent connections, but each connection will be fast. Currently, we are using prefork, configured as follows:
StartServers 5
MinSpareServers 5
MaxSpareServers 10
ServerLimit 600
MaxClients 600
MaxRequestsPerChild 0
We also have KeepAlive Off
I've played around with these setting quite a bit, and have been testing with apache benchmark. Anytime I raise the concurrent connections with ab, I get "apr_socket_recv: Connection reset by peer (104)." I've also raised the max number of file descriptors.
I'm wondering if any apache gurus out there can point me in the right direction for this type of setup (high number of lightweight connections). What are the optimum values for StartServers, Min/MaxSpareServers, etc? Is the worker MPM worth looking into? Any thoughts are welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可以给你一些提示:
StartServers
,MinSpareServers
和MaxSpareServers
。否则 Apache 正在以非常低的速度创建一个新的分叉:如果您认为您的服务器可以处理 600 个分叉,则使用 RAM,创建 600 个分叉,并可能将 MaxRequestsPerChild 设置更改为 3000 之类的值,这样有时旧的分叉会被删除并重新创建(避免 memleaks) 。您不会在分叉创建率上浪费任何时间,Apache 也不会在管理子进程的创建和删除方面浪费任何时间。
memory_limit
设置PHP 一个 PHP 进程的最大大小。I can give you some hints:
StartServers
,MinSpareServers
andMaxSpareServers
. else Apache is creating a new fork at a very low speed :if you think your server can handle 600 forks then take the RAM, create the 600 forks, and maybe alter the
MaxRequestsPerChild
setting to something like 3000, so that sometimes old forks are removed and recreated (avoiding memleaks). You will not losse any time in the fork creation rate and Apache will not loose any time managing creation and deletion of childrens.memory_limit
setting in PHP for the max size of one PHP process.