Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony 2. Migration project to php 7 from php5.5. Performance issues

I have one project ~4y old, I started with 5.3 and Symfony 2.0, migrated to 5.5 and S2.3. At the moment I migrated to S2.8 and I want to migrate to php 7.

As there was so much heap around PHP 7 performance I was eager to test my project performance in dev env.

So running benchmark in dev env; service is on vagrant host having both php5-fpm and php7.0-fpm, shutting one down and setting another up.

I would expect that php7 would outperform php5, but basically it seems that php7 is 1.5-2 times slower on my local dev env.

What am I doing wrong? Or should I rewrite my app somehow?

phpinfo: php 7 http://pastebin.com/a6a76vE2 php 5 http://pastebin.com/4GBXNmBB

P.S. Yes, I understand that running benchmarks in local dev env is not 100% valid and pure, but I need only to understand if php7 faster than php5, as it said.

U1

Funniest thing is that blackfire shows clearly that php 7 is ~45% faster than php 5. But when I am sieging, than I see that performance degrades.

U2

Here is more or less my custom configuration for dev env. It is the same for php5.5 and php7:

[Date]
date.timezone = Europe/Tallinn

[PHP]
memory_limit = 512M
expose_php = Off
cgi.fix_pathinfo = 0
post_max_size = 10M
upload_max_filesize = 10M
max_execution_time = 60
realpath_cache_size = 4096k
realpath_cache_ttl = 7200

error_reporting = E_ALL | E_STRICT
log_errors = On
error_log = /var/log/php.errors.log

display_errors = On
display_startup_errors = On
html_errors = On

; xdebug
xdebug.remote_enable = On
xdebug.remote_port = 9001
xdebug.max_nesting_level = 200
xdebug.remote_log = /tmp/xdebug.log
xdebug.remote_connect_back = on
xdebug.idekey = "vagrant"

[opcache]
opcache.enable_cli=0
opcache.save_comments=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=66000
opcache.fast_shutdown=1
opcache.enable=1
opcache.revalidate_freq=5
opcache.validate_timestamps=1
like image 431
Jevgeni Smirnov Avatar asked Apr 29 '16 18:04

Jevgeni Smirnov


1 Answers

Few steps to optimize PHP code globally and for PHP7 :

  • composer selfupdate
  • composer update
  • composer dumpautoload -a
  • activate zend opcache (or any other installed php opcache)
  • in php.ini :
    • opcache.max_accelerated_files=20000 (or more)
    • opcache.validate_timestamps=1
    • opcache.revalidate_freq=10 (or more)
    • xdebug.default_enable=0
  • restart php-fpm7 service

If performance issues still persist, profile your typical test page with blackfire.

like image 157
Takman Avatar answered Oct 23 '22 19:10

Takman