PHP-FPM 伺服器已耗盡

PHP-FPM 伺服器已耗盡

我正在建立一個「流量激增」應用程序,可以在幾分鐘內一次性處理 0 - 50,000 個客戶端。我想我會請求你們幫助理解我是否在這裡做錯了什麼。

目前,我正在使用 loader.io 進行測試,此負載測試的配置是 1 分鐘內 0 到 10,000 個用戶端。測試人員唯一要做的就是載入登入頁面,僅此而已,甚至沒有登入。

[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 個子進程。最簡單的「修復」是將最小和最大伺服器設定為相同的值,這樣,您就不需要等待它們啟動。

另外,如果可能的話,不要嘗試做類似的事情,而是嘗試實現緩存,因為它總是會更快。

相關內容