Test results showed that response speed improved by about 8 times just by switching from PHP standard application server 'PHP-FPM' to 'NGINX Unit'



NGINX Unit is an open source dynamic application server that can run in a variety of languages. Engineer straykerwl has reported test results that using NGINX Unit when running a PHP application improves response speed by about 8 times compared to using PHP-FPM.

Comparing PHP-FPM, NGINX Unit, and Laravel Octane / Habr

https://habr.com/en/articles/646397/

Service mesh infrastructure construction ~NGINX Unit - NGINX
https://www.nginx.co.jp/products/nginx-unit/


GitHub - nginx/unit: NGINX Unit
https://github.com/nginx/unit


In addition to PHP, NGINX Unit can run applications built in a variety of languages including Ruby, Go, Python, Java, Node.js, and Perl. It can be controlled using RESTful JSON API, and it also has the feature of being able to dynamically update the application while the service continues.



NGINX Unit is designed for distributed applications, and is expected to be used to connect various applications to build

a service mesh , but Streicherl is using the PHP framework ' Laravel ' on NGINX Unit. We have only verified that ' Lumen ' works.

The comparison targets are the commonly used PHP standard application server ' PHP-FPM ' and the Laravel specialized server ' Octane '. We conducted two types of tests: a ``standard test'' that applies a general load, and a ``stress test'' that tests the limits of access volume.

The results of the standard tests are shown in the table below. Each percentile of response time is listed in milliseconds. Comparing the numbers in the yellow background part of the 99th percentile, you can see that the combination of PHP-FPM + Laravel takes 60 ms to respond, while NGINX Unit + Laravel takes 7.6 ms, which is about 8 times faster. . Note that Octane is specialized, and even at the 99th percentile point, it only takes 1.23 milliseconds to process. 'HTTP OK %' on the far right means 'what percentage of requests were successfully processed', and it can be seen that in the standard test, all combinations were able to process 100% access.
99% 98% 95% 90% 85% 80% 75% 50% HTTP OK %
nginx + php-fpm + laravel 60 59 56 52 48 46 45 44 100
nginx + php-fpm + lumen 18 18 17 16 16 15 15 14 100
nginx-unit + laravel 7.6 7 6.5 5.8 5.3 5.2 5.2 4.059 100
nginx-unit + lumen 1.930 1.870 1.640 1.520 1.460 1.410 1.320 1.070 100
octane (swoole) + laravel 1.230 1.200 1.160 1.110 1.050 1.010 0.980 0.800 100


The results of a stress test that simulates a high-load environment are shown in the table below. As stated in the red background, PHP-FPM and Octane were unable to withstand the load and the request timed out. It is said that PHP-FPM + Laravel can no longer process when the number of requests exceeds 120 requests per second, and the combination of PHP-FPM + Lumen can only process up to 400 requests per second. Octane also dropped out at 600 requests per second, but NGINX Unit can stably process 1000 requests per second.
99% 98% 95% 90% 85% 80% 75% 50% HTTP OK %
* nginx + PHP-FPM + Laravel ~120 rps 62 59 55 52 49 47 45 43 -
* nginx + PHP-FPM + Lumen ~400 rps 34 twenty five 19 17 16 16 15 14 -
NGINX Unit + Laravel 6.6 6 5.5 5.2 4.96 4.7 4.5 3.79 100
NGINX Unit + Lumen 1.77 1.56 1.4 1.25 1.17 1.13 1.08 0.91 100
Octane (Swoole) + Laravel 18 8.3 4.85 3.88 3.45 3.1 2.85 1.87 82.807
* Octane (Swoole) + Laravel ~600 rps 3.23 3.01 2.85 2.55 2.2 2.029 1.92 0.78 -


In addition, another engineer ran WordPress on three types of platforms: PHP-FPM, NGINX Unit, and Apache and compared them, and concluded that NGINX Unit was superior in both stability and speed, as shown in the figure below.

in Software,   Web Service,   Web Application, Posted by log1d_ts