dpde7365 2016-04-29 18:12
浏览 153

Symfony 2.从php5.5迁移到php 7的项目。 性能问题

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
  • 写回答

2条回答 默认 最新

  • dstobkpm908182 2017-07-09 13:19
    关注

    The reason of this will surely be the xdebug. Please turn it off and then check the performance.

    I have to point out that in our case after switching from PHP5.5/Symfony 2.0 to PHP7/Symfony 3.0 we did encountered a performance drop. This was caused by how Symfony 2.8+ handles the php sessions. It stores them in a local directory instead of standard /tmp directory which almost always stored in RAM. So if you have pretty big count of session files the search of the file from HDD takes a long time compared to RAM.

    After removing this in Symfony config, the application started showing the performance gains we hoped for.

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!