Tuesday 15 September 2020

php-fpm Tuning

Target 1000 concurrent users untuk TAO

CPU 


CPU 10 core

$ cat /proc/cpuinfo | grep "model name"

model name : Intel(R) Xeon(R) Gold 5115 CPU @ 2.40GHz
model name : Intel(R) Xeon(R) Gold 5115 CPU @ 2.40GHz
model name : Intel(R) Xeon(R) Gold 5115 CPU @ 2.40GHz
model name : Intel(R) Xeon(R) Gold 5115 CPU @ 2.40GHz
model name : Intel(R) Xeon(R) Gold 5115 CPU @ 2.40GHz
model name : Intel(R) Xeon(R) Gold 5115 CPU @ 2.40GHz
model name : Intel(R) Xeon(R) Gold 5115 CPU @ 2.40GHz
model name : Intel(R) Xeon(R) Gold 5115 CPU @ 2.40GHz
model name : Intel(R) Xeon(R) Gold 5115 CPU @ 2.40GHz
model name : Intel(R) Xeon(R) Gold 5115 CPU @ 2.40GHz

Memory 

$free -g
              total        used        free      shared  buff/cache   available
Mem:             16           0          14           0           1          15
Swap:             0           0           0

Tuning

MySQL menggunakan konfigurasi seperti di jelaskan ... disini ..., Ketika concurent user 16 s.d 27, ke website utama, bukan TAO, MySQL memakan memory kurang lebih 800M s.d 900M.

Untuk mengetahui concurrent user, jalankan perintah : 

 $ netstat -plan | grep :80 | wc -l
 $ netstat -plan | grep :443 | wc -l


Terkadang, tiba-tiba server seperti hang tidak bisa menerima request sama sekali, menurut diskusi [7], solusi yg bisa dicoba mengubah kongurasi php-fpm.conf

emergency_restart_threshold=3

emergency_restart_interval=1m

process_control_timeout=5s


listen.backlog

fpm/pool.d/www.conf

listen.backlog = 65536

Pastikan limit OS nya melebihi diatas, jalankan : 

sysctl net.core.somaxconn 

echo "net.core.somaxconn=65536" >> /etc/sysctl.conf 

sysctl -p

Referensi

  1. PHP-FPM Process Calculator, https://spot13.com/pmcalculator/
  2. Optimizing PHP-FPM for High Performance,  https://geekflare.com/php-fpm-optimization/
  3. Performance enhacements for Apache and PHP, https://blog.bitnami.com/2014/06/performance-enhacements-for-apache-and.html
  4. Optimizing PHP Application Concurrency, https://devcenter.heroku.com/articles/php-concurrency
  5. PHP-FPM tuning for high load – The Best practices!, https://bobcares.com/blog/php-fpm-tuning-high-load/
  6. Moodle performance - examples of configurations, https://moodle.org/mod/forum/discuss.php?d=395623
  7. Optimizing NGINX and PHP-fpm for high traffic sites, http://www.softwareprojects.com/resources/programming/t-optimizing-nginx-and-php-fpm-for-high-traffic-sites-2081.html
  8. Constantly have to reload PHP-FPM, https://serverfault.com/questions/575457/constantly-have-to-reload-php-fpm
  9. Apache2 and php fpm performance optimization — Step-by-step guide, https://medium.com/@sbuckpesch/apache2-and-php-fpm-performance-optimization-step-by-step-guide-1bfecf161534
  10. What Are The Best PHP Accelerators?, https://wp-rocket.me/blog/best-php-accelerators/
  11. How to Enable and Monitor PHP-FPM Status in Nginx, https://www.tecmint.com/enable-monitor-php-fpm-status-in-nginx/
  12. PHP-FPM settings tutorial. max_servers, min_servers, etc., https://thisinterestsme.com/php-fpm-settings/