2018年に立ち上げた、t3.nano の WordPress と、今年立ち上げた、t4g.micro の WordPress でパフォーマンスを比較してみた。
メモリが0.5GBと1GBなので、純粋な比較にはならないんだけど、PHP8.0 で JITが有効な t3.nano と、JITが有効にならない t4g.micro でどっちが速いんだろうと気になるでしょ?
まず、t3.nano の PHP8.0 は JIT が On の状態。
1 2 3 4 |
$ php -i | grep JIT PCRE JIT Support => enabled PCRE JIT Target => x86 64bit (little endian + unaligned) JIT => On |
一方、t4g.micro の PHP8.0 は JIT が有効にできない。
1 2 3 4 |
$ php -i | grep JIT PCRE JIT Support => enabled PCRE JIT Target => ARM-64 64bit (little endian + unaligned) JIT => Not Available |
どちらも、Webサーバーは h2o 2.3、PHP 8.1、MariaDB 10.2。最大同時接続数やキャッシュ関係は、t3.nano でも動くよう極力絞った値としていて、どちらも同様の設定。
h2load を使って同時接続10で1000接続を計測。
まずは、t3.nano の結果がこちら。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
$ h2load -n 1000 -c 10 https://127.0.0.1/ starting benchmark... spawning thread #0: 10 total client(s). 1000 total requests TLS Protocol: TLSv1.2 Cipher: ECDHE-RSA-AES256-GCM-SHA384 Server Temp Key: ECDH P-256 256 bits Application protocol: h2 progress: 10% done progress: 20% done progress: 30% done progress: 40% done progress: 50% done progress: 60% done progress: 70% done progress: 80% done progress: 90% done progress: 100% done finished in 85.73s, 11.67 req/s, 1.04MB/s requests: 1000 total, 1000 started, 1000 done, 1000 succeeded, 0 failed, 0 errored, 0 timeout status codes: 1000 2xx, 0 3xx, 0 4xx, 0 5xx traffic: 89.21MB (93543807) total, 28.07KB (28748) headers (space savings 84.95%), 89.08MB (93411000) data min max mean sd +/- sd time for request: 334.48ms 1.18s 853.06ms 63.80ms 81.00% time for connect: 18.21ms 19.32ms 18.73ms 362us 60.00% time to 1st byte: 185.14ms 792.49ms 482.84ms 278.20ms 70.00% req/s : 1.17 1.18 1.17 0.01 80.00% |
続いて、t4g.micro の結果がこちら。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
h2load -n 1000 -c 10 https://127.0.0.1/ starting benchmark... spawning thread #0: 10 total client(s). 1000 total requests TLS Protocol: TLSv1.2 Cipher: ECDHE-RSA-AES256-GCM-SHA384 Server Temp Key: ECDH P-256 256 bits Application protocol: h2 progress: 10% done progress: 20% done progress: 30% done progress: 40% done progress: 50% done progress: 60% done progress: 70% done progress: 80% done progress: 90% done progress: 100% done finished in 69.83s, 14.32 req/s, 1.27MB/s requests: 1000 total, 1000 started, 1000 done, 1000 succeeded, 0 failed, 0 errored, 0 timeout status codes: 1000 2xx, 0 3xx, 0 4xx, 0 5xx traffic: 89.00MB (93320985) total, 24.44KB (25029) headers (space savings 86.96%), 88.88MB (93197000) data min max mean sd +/- sd time for request: 145.68ms 883.37ms 693.73ms 55.28ms 80.30% time for connect: 47.32ms 49.32ms 48.09ms 728us 60.00% time to 1st byte: 179.50ms 629.88ms 371.90ms 190.44ms 70.00% req/s : 1.43 1.45 1.44 0.01 70.00% |
JITを有効にした t3.nano より、JIT無効の t4g.nano の方が 1.2倍くらい速い。
おそらく、PHP自体は JIT が有効な t3.nano の方が高速なんだろうけど、総合力では t4g.micro の方が速いみたい。
ついでに t3.nano で JIT を無効にした場合の結果はこんな感じ。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
$ h2load -n 1000 -c 10 https://127.0.0.1/ starting benchmark... spawning thread #0: 10 total client(s). 1000 total requests TLS Protocol: TLSv1.2 Cipher: ECDHE-RSA-AES256-GCM-SHA384 Server Temp Key: ECDH P-256 256 bits Application protocol: h2 progress: 10% done progress: 20% done progress: 30% done progress: 40% done progress: 50% done progress: 60% done progress: 70% done progress: 80% done progress: 90% done progress: 100% done finished in 95.56s, 10.46 req/s, 956.03KB/s requests: 1000 total, 1000 started, 1000 done, 1000 succeeded, 0 failed, 0 errored, 0 timeout status codes: 1000 2xx, 0 3xx, 0 4xx, 0 5xx traffic: 89.21MB (93547906) total, 31.14KB (31884) headers (space savings 83.31%), 89.08MB (93411000) data min max mean sd +/- sd time for request: 257.88ms 1.21s 951.78ms 62.52ms 78.30% time for connect: 20.51ms 24.14ms 22.99ms 1.30ms 80.00% time to 1st byte: 224.77ms 911.30ms 555.59ms 339.11ms 80.00% req/s : 1.05 1.06 1.05 0.00 50.00% |
さらに遅くなった。
ちなみに実行中の top の状態はこんな感じ。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
【t3.nano】 top - 22:05:45 up 117 days, 20:28, 2 users, load average: 3.61, 1.13, 0.40 Tasks: 99 total, 6 running, 55 sleeping, 0 stopped, 0 zombie %Cpu0 : 96.3 us, 3.7 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu1 : 98.3 us, 1.7 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 470080 total, 8924 free, 350396 used, 110760 buff/cache KiB Swap: 0 total, 0 free, 0 used. 72156 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 2900 h2o 20 0 479496 72032 44544 R 41.2 15.3 0:07.49 php-fpm 2896 h2o 20 0 480080 72572 44544 R 40.2 15.4 0:09.41 php-fpm 2897 h2o 20 0 480020 72572 44544 R 38.5 15.4 0:08.08 php-fpm 2899 h2o 20 0 479024 71516 44544 R 38.2 15.2 0:07.12 php-fpm 2898 h2o 20 0 479724 72360 44544 R 37.5 15.4 0:07.77 php-fpm 2299 mysql 20 0 1844860 126968 9664 S 2.3 27.0 0:05.64 mysqld 2448 h2o 20 0 355344 11716 5476 S 1.0 2.5 0:01.63 h2o 2883 ec2-user 20 0 155200 7824 6236 S 0.7 1.7 0:00.37 h2load 【t4g.micro】 top - 22:09:05 up 62 days, 2:32, 2 users, load average: 1.48, 1.21, 0.58 Tasks: 137 total, 6 running, 85 sleeping, 0 stopped, 0 zombie %Cpu0 : 94.3 us, 5.7 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu1 : 97.0 us, 3.0 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 978180 total, 221472 free, 318976 used, 437732 buff/cache KiB Swap: 0 total, 0 free, 0 used. 550204 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 13489 h2o 20 0 279424 71836 43436 R 39.0 7.3 0:05.67 php-fpm 13492 h2o 20 0 279436 66128 37864 R 37.7 6.8 0:05.16 php-fpm 13491 h2o 20 0 279588 66212 37836 R 37.0 6.8 0:05.15 php-fpm 13493 h2o 20 0 279608 66076 37612 R 36.7 6.8 0:05.28 php-fpm 13490 h2o 20 0 279272 65796 37596 R 36.0 6.7 0:05.04 php-fpm 7207 mysql 20 0 1380836 78260 23208 S 2.7 8.0 0:04.97 mariadbd 13522 h2o 20 0 328748 15384 7108 S 0.7 1.6 0:00.18 h2o 13549 ec2-user 20 0 91940 7040 5720 S 0.3 0.7 0:00.07 h2load |
h2o や mysqld はそんなに負荷がかかっていない。
まだ、6月末までは t4g.micro が無料なので、このまま使ってみることにしました。