簡體   English   中英

Php-fpm & Nginx 在 docker 容器性能

[英]Php-fpm & Nginx in docker conatainer performance

我們正在開發一個同時具有高流量的在線考試系統,該系統使用 laravel 和 MySQL 作為數據庫開發。 我們的服務器有 40 核和 64 GB RAM memory。 I installed Nginx in a docker container PHP in another container Mysql in another container, also we tested the system with the classic way, where all services working in the same server directly without docker. 但問題是系統不能同時處理超過 600 個用戶。 我們嘗試了 Nginx 性能調整和沒有任何工作,以及 php-fpm。 我不知道為什么會發生這種情況,我們嘗試了所有可以提供幫助但無濟於事的架構,每個 PHP-fpm 進程使用 27% 的 CPU。 當我使用

ApacheBench

為了向服務器發送請求,然后嘗試從我的瀏覽器加載主頁,需要很長時間才能響應頁面並且多次返回超時。 我正在使用Nginx:stable-alpine作為 Nginx docker 圖像。

php:7.4-fpm-alpine

作為 PHP 圖像。 我沒有更改 PHP 或 Nginx 的任何默認配置。 那么為了獲得最佳性能,我必須應用 PHP 和 Nginx 的最佳配置是什么?

發送請求前的 htop 結果在此處輸入圖像描述

使用發送請求后的 htop

sudo ab -n 5000 -c 600 https://demo.qsinav.com/

在此處輸入圖像描述

每秒速率 = RPS

為您的 my.cnf [mysqld] 部分考慮的建議

thread_cache_size=100  # from 9 to reduce threads_created RPhr of 78 
net_buffer_length=32K  # from 16K to reduce # packets per hour 
query_cache_size=0  # from 1M to conserve RAM because the QCtype of OFF
slow_query_log=ON  # from OFF to allow awareness and proactively correct
long_query_time=1  # from 10 seconds - if overwhelmed with entries, raise the seconds by 1 
innodb_write_io_threads=64  # from 4 to expedite writing to tables on storage devices

還有更多改進配置的機會。 查看配置文件,網絡配置文件可免費下載實用程序腳本以幫助進行性能調整,特別是 findfragtables。sql 有助於提醒您定期優化使用頻繁的表。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM