PHP-FPM 服务器已耗尽

PHP-FPM 服务器已耗尽

我正在开发一款“激增流量”应用,该应用可以在几分钟内同时从 0 增加到 50,000 个客户端。我想请你们帮忙了解我是否做错了什么。

目前,我正在使用 loader.io 进行测试,我为这次负载测试配置的是 1 分钟内 0 到 10,000 个客户端。测试人员唯一要做的就是加载登录页面,仅此而已,甚至没有登录。页面大小为 793KB,相当于真实浏览器上的加载时间约为 400ms。

[01-Mar-2018 09:57:48] WARNING: [pool app.com] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 4244 idle, and 4607 total children
[01-Mar-2018 09:57:49] WARNING: [pool app.com] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 4216 idle, and 4615 total children
[01-Mar-2018 09:57:50] WARNING: [pool app.com] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 4211 idle, and 4631 total children
[01-Mar-2018 09:57:52] WARNING: [pool app.com] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 4179 idle, and 4663 total children
[01-Mar-2018 09:57:54] WARNING: [pool app.com] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 4181 idle, and 4695 total children
[01-Mar-2018 09:57:57] WARNING: [pool app.com] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 4244 idle, and 4727 total children
[01-Mar-2018 09:57:58] WARNING: [pool app.com] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 4412 idle, and 4759 total children

我的php-fpm配置如下:

pm.max_children 3000
pm.max_requests 200
pm  dynamic
pm.start_servers 1500
pm.min_spare_servers 300
pm.max_spare_servers 1500

主机服务器规格:

AMD Opteron(tm) Processor 6344

Core Name
Abu Dhabi
# of Cores
12-Core
# of Threads
12
Operating Frequency
2.6 GHz
Hyper Transports
6.40 GT/s
L2 Cache
6 x 2MB
L3 Cache
2 x 8MB
Manufacturing Tech
32 nm

50GB RAM (I have provided this to the container), server has 64 total.

奇怪的是,即使采用了这种配置,我仍然收到“似乎很忙”的消息!

这里就是事物消亡的地方: 在此处输入图片描述

这里要记住的最重要的事情是,通常我们的流量很少甚至没有,但我们预计几分钟内用户数量将达到 50,000。你们能帮我解决这个错误吗?谢谢!

答案1

您需要记住,启动这些额外的工作进程需要时间,正如您在日志中看到的那样,php-fpm 一次会生成 32 个子进程。最简单的“修复”方法是将最小和最大服务器设置为相同的值,这样,您就不需要等待它们启动了。

如果可能的话,不要尝试做这样的事情,而是尝试实现缓存,因为这样总是更快。

相关内容