:::

8-4 網站伺服器效能優化

  1. 可先參考以下文件:
    1. https://gist.github.com/holmberd/44fa5c2555139a1a46e01434d3aaa512
    2. https://blog.gtwang.org/linux/nginx-php-fpm-configuration-optimization/
    3. https://www.kancloud.cn/digest/php-src/136260
  2. 找出目前可用記憶體:
    free -h
    root@ic:/etc/php/7.3/fpm/pool.d# free -h
                  total        used        free      shared  buff/cache   available
    Mem:          7.8Gi       988Mi       514Mi        39Mi       6.3Gi       6.7Gi
    Swap:         2.0Gi        30Mi       2.0Gi

    先計算每個php行程需要的記憶體,例如:38M
    ps --no-headers -o "rss,cmd" -C php-fpm7.3 | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }'

    計算max_children數

    (6.7*1024)/38=180

     

  3. 編輯php的設定檔
    vi /etc/php/7.3/fpm/pool.d/www.conf

    修改以下幾個設定項目:

    pm.max_children = 180
    pm.start_servers = 20
    pm.min_spare_servers = 5
    pm.max_spare_servers = 35
    pm.max_request = 10000

     

  4. 最後重啟PHP
    systemctl restart php7.3-fpm

     


:::

書籍目錄

展開 | 闔起

QR Code 區塊

http%3A%2F%2Fcampus-xoops.tn.edu.tw%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbdsn%3D1550

計數器

今天: 1212121212121212
昨天: 1243124312431243
總計: 3227401322740132274013227401322740132274013227401