Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Magento PHP7.4 Preload vs PHP 7.3 results.md

Current Magento 2.2.2 PHP 7.4 with preload is 10%+ faster

Comparison of means

PHP 7.4 with preload is 11.07% faster then PHP 7.3

PHP 7.4 with preload is 13.25% faster then PHP 7.1

Sample 1 PHP 7.4 with Preload

Mean: 0.458

Standard deviation: 0.0411

Sample size: 1000

Sample 2 PHP 7.3

Mean: 0.515

Standard deviation: 0.0877

Sample size: 1000

Sample 2 PHP 7.1

Mean: 0.528

Standard deviation: 0.0361

Sample size: 1000

Results

Difference 0.057

Standard error 0.003 95% CI 0.0510 to 0.0630 t-statistic 18.611 DF 1998 Significance level P < 0.0001

Data of the test

With preload

:php kir.morozov$ php-edge-unload && sleep 3s && ab -n 100 http://m2.loc2/
--->  Loading startupitem 'php73-fpm' for php73-fpm
This is ApacheBench, Version 2.3 <$Revision: 1826891 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking m2.loc2 (be patient).....done  


Server Software:        nginx/1.15.9
Server Hostname:        m2.loc2
Server Port:            80

Document Path:          /
Document Length:        215496 bytes

Concurrency Level:      1
Time taken for tests:   51.540 seconds
Complete requests:      100
Failed requests:        0
Total transferred:      21619800 bytes
HTML transferred:       21549600 bytes
Requests per second:    1.94 [#/sec] (mean)
Time per request:       515.395 [ms] (mean)
Time per request:       515.395 [ms] (mean, across all concurrent requests)
Transfer rate:          409.65 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       1
Processing:   398  515 294.2    460    3323
Waiting:      397  513 294.2    459    3322
Total:        399  515 294.2    460    3323

Percentage of the requests served within a certain time (ms)
  50%    460
  66%    501
  75%    518
  80%    534
  90%    607
  95%    720
  98%    801
  99%   3323
 100%   3323 (longest request)
:php kir.morozov$ sleep 3s && ab -n 100 http://m2.loc2/
This is ApacheBench, Version 2.3 <$Revision: 1826891 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking m2.loc2 (be patient).....done


Server Software:        nginx/1.15.9
Server Hostname:        m2.loc2
Server Port:            80

Document Path:          /
Document Length:        215496 bytes

Concurrency Level:      1
Time taken for tests:   46.709 seconds
Complete requests:      100
Failed requests:        0
Total transferred:      21619800 bytes
HTML transferred:       21549600 bytes
Requests per second:    2.14 [#/sec] (mean)
Time per request:       467.089 [ms] (mean)
Time per request:       467.089 [ms] (mean, across all concurrent requests)
Transfer rate:          452.01 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       1
Processing:   392  466 108.6    445    1462
Waiting:      390  465 108.6    444    1460
Total:        392  467 108.6    446    1462

Percentage of the requests served within a certain time (ms)
  50%    446
  66%    466
  75%    481
  80%    491
  90%    521
  95%    557
  98%    585
  99%   1462
 100%   1462 (longest request)
:php kir.morozov$ sleep 3s && ab -c2 -n 1000 http://m2.loc2/
This is ApacheBench, Version 2.3 <$Revision: 1826891 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking m2.loc2 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        nginx/1.15.9
Server Hostname:        m2.loc2
Server Port:            80

Document Path:          /
Document Length:        215496 bytes

Concurrency Level:      2
Time taken for tests:   258.342 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      216198000 bytes
HTML transferred:       215496000 bytes
Requests per second:    3.87 [#/sec] (mean)
Time per request:       516.683 [ms] (mean)
Time per request:       258.342 [ms] (mean, across all concurrent requests)
Transfer rate:          817.25 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.2      0       3
Processing:   399  515  87.7    511    1635
Waiting:      397  512  87.4    509    1631
Total:        400  515  87.7    511    1635

Percentage of the requests served within a certain time (ms)
  50%    511
  66%    526
  75%    532
  80%    539
  90%    563
  95%    604
  98%    722
  99%    869
 100%   1635 (longest request)

With PHP Preload

:php kir.morozov$ php-edge-load && sleep 3s && ab -n 100 http://m2.loc2/
--->  Unloading startupitem 'php73-fpm' for php73-fpm
This is ApacheBench, Version 2.3 <$Revision: 1826891 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking m2.loc2 (be patient).....done


Server Software:        nginx/1.15.9
Server Hostname:        m2.loc2
Server Port:            80

Document Path:          /
Document Length:        210652 bytes

Concurrency Level:      1
Time taken for tests:   49.679 seconds
Complete requests:      100
Failed requests:        0
Total transferred:      21135800 bytes
HTML transferred:       21065200 bytes
Requests per second:    2.01 [#/sec] (mean)
Time per request:       496.787 [ms] (mean)
Time per request:       496.787 [ms] (mean, across all concurrent requests)
Transfer rate:          415.48 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       1
Processing:   369  496 370.2    440    4092
Waiting:      367  494 370.1    438    4090
Total:        369  496 370.2    440    4093

Percentage of the requests served within a certain time (ms)
  50%    440
  66%    452
  75%    472
  80%    486
  90%    541
  95%    667
  98%    803
  99%   4093
 100%   4093 (longest request)
:php kir.morozov$ sleep 3s && ab -c2 -n 1000 http://m2.loc2/
This is ApacheBench, Version 2.3 <$Revision: 1826891 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking m2.loc2 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        nginx/1.15.9
Server Hostname:        m2.loc2
Server Port:            80

Document Path:          /
Document Length:        210652 bytes

Concurrency Level:      2
Time taken for tests:   229.723 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      211358000 bytes
HTML transferred:       210652000 bytes
Requests per second:    4.35 [#/sec] (mean)
Time per request:       459.445 [ms] (mean)
Time per request:       229.723 [ms] (mean, across all concurrent requests)
Transfer rate:          898.49 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   0.1      1       1
Processing:   376  457  41.1    449     678
Waiting:      375  455  41.0    447     676
Total:        377  458  41.1    450     678

Percentage of the requests served within a certain time (ms)
  50%    450
  66%    467
  75%    485
  80%    493
  90%    512
  95%    529
  98%    555
  99%    592
 100%    678 (longest request)

PHP 7.1

$  sleep 3s && ab -n 100 http://m2.loc2/
This is ApacheBench, Version 2.3 <$Revision: 1826891 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking m2.loc2 (be patient).....done


Server Software:        nginx/1.15.9
Server Hostname:        m2.loc2
Server Port:            80

Document Path:          /
Document Length:        215496 bytes

Concurrency Level:      1
Time taken for tests:   58.168 seconds
Complete requests:      100
Failed requests:        0
Total transferred:      21619900 bytes
HTML transferred:       21549600 bytes
Requests per second:    1.72 [#/sec] (mean)
Time per request:       581.683 [ms] (mean)
Time per request:       581.683 [ms] (mean, across all concurrent requests)
Transfer rate:          362.97 [Kbytes/sec] received

Connection Times (ms)
             min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       1
Processing:   414  581 437.6    519    4774
Waiting:      403  570 437.0    508    4757
Total:        414  581 437.6    519    4774

Percentage of the requests served within a certain time (ms)
 50%    519
 66%    530
 75%    543
 80%    553
 90%    660
 95%    825
 98%   1278
 99%   4774
100%   4774 (longest request)
:php kir.morozov$ sleep 3s && ab -c2 -n 1000 http://m2.loc2/
This is ApacheBench, Version 2.3 <$Revision: 1826891 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking m2.loc2 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        nginx/1.15.9
Server Hostname:        m2.loc2
Server Port:            80

Document Path:          /
Document Length:        215496 bytes

Concurrency Level:      2
Time taken for tests:   264.837 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      216199000 bytes
HTML transferred:       215496000 bytes
Requests per second:    3.78 [#/sec] (mean)
Time per request:       529.674 [ms] (mean)
Time per request:       264.837 [ms] (mean, across all concurrent requests)
Transfer rate:          797.21 [Kbytes/sec] received

Connection Times (ms)
             min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       2
Processing:   429  528  36.1    523     810
Waiting:      418  515  35.9    511     798
Total:        429  528  36.1    524     811

Percentage of the requests served within a certain time (ms)
 50%    524
 66%    535
 75%    543
 80%    551
 90%    567
 95%    587
 98%    613
 99%    655
100%    811 (longest request)
@adhocore

This comment has been minimized.

Copy link

@adhocore adhocore commented Feb 20, 2020

great. does magento already support PHP7.4? i dint see it mentioned in their docs though.
would you like to share how did you setup magento with PHP7.4 for this benchmark?

@kirmorozov

This comment has been minimized.

Copy link
Owner Author

@kirmorozov kirmorozov commented Jan 11, 2021

@adhocore sorry for late reply, it was dummy test environment, nothing special.
The only difference was opcode.preload which did preload of classes and files used at most used pages.
This way you must restart php-fpm or apache because opcode load happens before process fork.

@Stepa4man

This comment has been minimized.

Copy link

@Stepa4man Stepa4man commented Feb 10, 2021

What script do you use for preloading? Just manually created a PHP script file with require once 'absolute/path/for/class.file'?

@HOSTED-POWER

This comment has been minimized.

Copy link

@HOSTED-POWER HOSTED-POWER commented Aug 23, 2021

I wonder too, do you have any sample at hand? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment