24

I've tried to reproduce this benchmark which compares PHP 7 with older versions on a Wordpress server: http://talks.php.net/oz15#/wpbench

My configuration is nearly the same, the server has an i7, SSD, 16GB RAM and debian. The server software is nginx. Suprisingly my results differ a lot from the ones linked above.

In my tests Siege (https://www.joedog.org/siege-home/) outputs the following:

For PHP 7.0.0RC1:

siege -c100 -r100 http://10.22.255.133/wordpress/
** SIEGE 3.0.8
** Preparing 100 concurrent users for battle.
The server is now under siege..      done.

Transactions:                  10000 hits
Availability:                  100.00 %
Elapsed time:                  131.61 secs
Data transferred:              95.77 MB
Response time:                 0.75 secs
Transaction rate:              75.98 trans/sec
Throughput:                    0.73 MB/sec
Concurrency:                   56.98
Successful transactions:       10000
Failed transactions:           0
Longest transaction:           1.01
Shortest transaction:          0.04

For PHP 5.6.12:

siege -c100 -r100 http://10.22.255.133/wordpress/
** SIEGE 3.0.8
** Preparing 100 concurrent users for battle.
The server is now under siege..      done.

Transactions:                  10000 hits
Availability:                  100.00 %
Elapsed time:                  63.41 secs
Data transferred:              95.77 MB
Response time:                 0.03 secs
Transaction rate:              157.70 trans/sec
Throughput:                    1.51 MB/sec
Concurrency:                   4.45
Successful transactions:       10000
Failed transactions:           0
Longest transaction:           0.63
Shortest transaction:          0.01

When looking at the transaction rate you can see, that PHP 5 is about two times faster than PHP 7. I can't believe that.

Another interesting fact is, that running this benchmark (http://www.php-benchmark-script.com/) results in PHP 7 being about 3 times faster than PHP 5 (of course on the same server where I've also tested Wordpress). The measured results were:

  • PHP 7.0.0RC1 | PHP 5.5.28
  • Math: 0.201 | 0.683
  • String Manipulation: 0.271 | 0.77
  • Loops: 0.166 | 0.486
  • If Else: 0.12 | 0.295

I've uploaded both phpinfo() files in case that helps:

Do you have any idea why PHP 7 is that much slower in my tests with Wordpress?


With opcache enabled PHP 7 is actually twice as fast as PHP 5. Thanks Mjh for your hint!

I've made the following measurements on a randomly filled WordPress Server.

Siege now outputs the following for PHP 7.0.0RC1:

Transactions:                  10000 hits
Availability:                 100.00 %
Elapsed time:                  62.14 secs
Data transferred:             604.20 MB
Response time:                  0.02 secs
Transaction rate:             160.93 trans/sec
Throughput:                     9.72 MB/sec
Concurrency:                    3.77
Successful transactions:       10000
Failed transactions:               0
Longest transaction:            0.41
Shortest transaction:           0.01 

And PHP 5.6.12:

siege -c100 -r100 http://10.22.255.133/wordpress/
** SIEGE 3.0.8
** Preparing 100 concurrent users for battle.
The server is now under siege..      done.

Transactions:                 10000 hits
Availability:                 100.00 %
Elapsed time:                 119.98 secs
Data transferred:             604.20 MB
Response time:                0.60 secs
Transaction rate:             83.35 trans/sec
Throughput:                   5.04 MB/sec
Concurrency:                  49.86
Successful transactions:      10000
Failed transactions:          0
Longest transaction:          4.06
Shortest transaction:         0.04
9
  • 2
    Did you turn off session support for the test? Also, did you run siege on the same machine where nginx and php-fpm are installed?
    – Mjh
    Sep 1, 2015 at 9:58
  • Thanks for your response! Session support is disabled and Siege is running on another machine in the local network. I also made sure that the network is not a limiting factor.
    – Timo Denk
    Sep 1, 2015 at 12:15
  • 5
    Is the php-fpm config the same for both php versions? Also, it appears that opcache isn't enabled for your php 7, while it is for php 5. That alone can amount for huge difference..
    – Mjh
    Sep 1, 2015 at 12:21
  • 1
    Thanks for posting that. You could most likely go even higher with the requests per second, but I assume you're quite ok with the results you're seeing now.
    – Mjh
    Sep 1, 2015 at 15:13
  • 1
    I think it might also be worth noting that Wordpress has history when it comes to benchmarking "faster" versions of PHP. HHVM ~ 2-3 years back was claiming 6x speed improvements against most major PHP 5.2 frameworks, but Wordpress was less that 2x the speed. Still faster, but a little disappointing. (Sorry, can't find a reference)
    – DanielM
    Sep 21, 2015 at 14:54

2 Answers 2

21

According to the output of phpinfo you posted, opcache isn't enabled for your PHP 7, while it is for PHP 5. That alone can amount for a huge difference.

1
  • Posted Mjh's answer from comment as community wiki so this question can be marked as solved. @Simsso, please accept this answer if it resolved your issue. Sep 24, 2015 at 18:53
-2

I currently have the same surprising results on the CLI side.

One of my old projects uses a PHING build. It was running on PHP 5.3 then PHP 5.6. I tried using PHP 7 and noticed a huge difference. So i decided to time the script execution.

FYI it is a real life projects with thousands of files processed during the build.

Build using PHP 5.3.29: 3 minutes and 44 seconds elapsed.

Build using PHP 7.2.11: 11 minutes and 41 seconds elapsed.

I noticed the CLI did not have opcache activated, here is the results with opcache:

Build using PHP 7.2.11 + opcache: 12 minutes and 18 seconds elapsed.

Yes, WORSE

FYI:

$ php --info |grep opcache
opcache.blacklist_filename => no value => no value
opcache.consistency_checks => 0 => 0
opcache.dups_fix => Off => Off
opcache.enable => On => On
opcache.enable_cli => On => On
opcache.enable_file_override => Off => Off
opcache.error_log => no value => no value
opcache.file_cache => no value => no value
opcache.file_cache_consistency_checks => 1 => 1
opcache.file_cache_only => 0 => 0
opcache.file_update_protection => 2 => 2
opcache.force_restart_timeout => 180 => 180
opcache.huge_code_pages => Off => Off
opcache.inherited_hack => On => On
opcache.interned_strings_buffer => 8 => 8
opcache.lockfile_path => /tmp => /tmp
opcache.log_verbosity_level => 1 => 1
opcache.max_accelerated_files => 10000 => 10000
opcache.max_file_size => 0 => 0
opcache.max_wasted_percentage => 5 => 5
opcache.memory_consumption => 128 => 128
opcache.opt_debug_level => 0 => 0
opcache.optimization_level => 0x7FFFBFFF => 0x7FFFBFFF
opcache.preferred_memory_model => no value => no value
opcache.protect_memory => 0 => 0
opcache.restrict_api => no value => no value
opcache.revalidate_freq => 2 => 2
opcache.revalidate_path => Off => Off
opcache.save_comments => 1 => 1
opcache.use_cwd => On => On
opcache.validate_permission => Off => Off
opcache.validate_root => Off => Off
opcache.validate_timestamps => On => On

Btw, I have to say I never noticed a huge difference on prod with apache when switched from PHP 5 to PHP 7. Despites all of the bechmarks we see online, the difference is far from obvious.

Neddless to say, for that project, I will stick to PHP 5 version.

1
  • Someone downvoted my comment, should I post a video to prove what I said? ;-)
    – Nadir
    Feb 17, 2019 at 23:21

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.