:::

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

     


:::

書籍目錄

展開 | 闔起

快速登入


https%3A%2F%2Fcampus-xoops.tn.edu.tw%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbdsn%3D1550%26tbsn%3D15

計數器

今天: 5074507450745074
昨天: 2489248924892489
總計: 8027056802705680270568027056802705680270568027056