Upgrade to Pro — share decks privately, control downloads, hide ads and more …

こまけぇこたぁいいんだよ!! PHPWebアプリケーションを早くする、それだけだ / It doesn't matter how small it is! Make PHPWeb applications faster, that's all!

こまけぇこたぁいいんだよ!! PHPWebアプリケーションを早くする、それだけだ / It doesn't matter how small it is! Make PHPWeb applications faster, that's all!

PHPカンファレンス関西2024

shiro seike

February 11, 2024
Tweet

More Decks by shiro seike

Other Decks in Programming

Transcript

  1. 自己 @seike 46 0 - - @seike 46 0 -

    AWS Community Builder Serverless - Fusic - / 門 - / - 月 PHP - PHP 2024 LT ( ) - PHP 大 2024 LT (Now ) - PHPerKaigi 20 2 4 LT - PHP 小 田 2024 - PHP 香 2024 - PHP 2024 2
  2. 01

  3. 用 - Web - DB -   c 5 .large

    vCPU 2 4 GiB 20GiB 7
  4. 02

  5. 03

  6. 方 pgrep   phpspy 用     12 $ ./phpspy

    -b 81 920 --limit= 1 00 0 0 --pid=$(pgrep -n php-fpm) > traces $ ./stackcollapse-phpspy.pl <traces | ./vendor/flamegraph.pl >flame.svg
  7. 04

  8. DB PHP 入 Web DB 16 SCORE: 13 27 (+

    132 7 0 ( 0 %)) SCORE: 14 69 (+ 146 9 0 ( 0 %))
  9. DB PHP 入 Web DB DB 19 SCORE: 13 27

    (+ 132 7 0 ( 0 %)) SCORE: 14 69 (+ 146 9 0 ( 0 %)) SCORE: 16 95 (+ 169 5 0 ( 0 %))
  10. Index DB Index pt-query-digest 用 20 ALTER TABLE visit_history DROP

    INDEX tenant_id_idx; ALTER TABLE visit_history ADD INDEX tenant_id_idx(tenant_id, competition_id, player_id, created_at);
  11. Index PHP 入 Web DB DB Index 21 SCORE: 13

    27 (+ 132 7 0 ( 0 %)) SCORE: 14 69 (+ 146 9 0 ( 0 %)) SCORE: 16 95 (+ 169 5 0 ( 0 %)) SCORE: 18 67 (+ 186 7 0 ( 0 %))
  12. N+ 1 PHP 入 Web DB DB Index N+ 1

    23 SCORE: 13 27 (+ 132 7 0 ( 0 %)) SCORE: 14 69 (+ 146 9 0 ( 0 %)) SCORE: 16 95 (+ 169 5 0 ( 0 %)) SCORE: 18 67 (+ 186 7 0 ( 0 %)) SCORE: 24 33 (+ 243 3 0 ( 0 %))
  13. Nginx - worker_processes -> auto - worker_connections - keepalive_timeout 入

    gzip gzip_vary gzip_proxied gzip_comp_level gzip_buffers gzip_http_version 24
  14. php-fpm 25 Fork Process Process - pm.max_children - pm.start_servers -

    pm.min_spare_servers - pm.max_spare_servers - rlimit_files
  15. php-fpm 26 OPcache PHP 8 目玉 JIT PHP 入 OPcache

    opcache.enable JIT opcache.jit opcache.jit_buffer_size opcache.max_accelerated_files opcache.memory_consumption opcache.validate_timestamps XDebug
  16. OS OS   大 ⾒ ulimit     大  

      net.core.somaxconn vm.swappiness fs.file-max 27
  17. Nginx + php-fpm + OS PHP 入 Web DB DB

    Index N+ 1 Nginx + php-fpm + OS 28 SCORE: 13 27 (+ 132 7 0 ( 0 %)) SCORE: 14 69 (+ 146 9 0 ( 0 %)) SCORE: 16 95 (+ 169 5 0 ( 0 %)) SCORE: 18 67 (+ 186 7 0 ( 0 %)) SCORE: 24 33 (+ 243 3 0 ( 0 %)) SCORE: 30 12 (+ 301 2 0 ( 0 %))