Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php 5.6 performance issues #139

Closed
andrewklau opened this issue Dec 19, 2016 · 16 comments
Closed

php 5.6 performance issues #139

andrewklau opened this issue Dec 19, 2016 · 16 comments
Assignees

Comments

@andrewklau
Copy link
Contributor

andrewklau commented Dec 19, 2016

We have been receiving increased reports for performance issues with the 5.6 image.

5.6 has issues with slow response times which often leads to gateway timeouts etc.

Downgrading/upgrading to 5.5/7.0 resolve the problem.

@bparees
Copy link
Collaborator

bparees commented Dec 19, 2016

can you elaborate? what sort of performance issue? memory usage? cpu? during build? application runtime? has it gone up from previous versions of the 5.6 image? how does it compare with the same metrics for the 5.5 image?

@andrewklau
Copy link
Contributor Author

andrewklau commented Dec 19, 2016

Sorry edited my initial message just as you replied.

Applications running with 5.6 are significantly slower to respond which often leads to 504 responses
Switching to use 5.5 or 7.0 do not have the problem and they perform much faster

It's not a resource issue as metrics do not report any limits being reached

@bparees
Copy link
Collaborator

bparees commented Dec 20, 2016

Can you define significantly? does this apply to trivial(hello world) apps? Have you done any profiling to see where the time is being spent?

@andrewklau
Copy link
Contributor Author

andrewklau commented Dec 20, 2016 via email

@andrewklau
Copy link
Contributor Author

Here is just some basic tests a customer ran, this seems to run slower across all the PHP images (in comparison to local PHP and an OpenShift 2 cluster):

time php test.php

<?php

function tryAlloc($megabyte){ 
echo "try allocating {$megabyte} megabyte..."; 
$mark = microtime(true); 
$dummy = str_repeat("-",1048576*$megabyte); 
echo "allocation time : " . sprintf("%f", microtime(true)-$mark) . "\n"; 
echo "Usage: " . memory_get_usage(true)/1048576; 
echo " Peak: " . memory_get_peak_usage(true)/1048576; 
echo "\n"; 
}

tryAlloc(1); 
tryAlloc(10); 
tryAlloc(20); 
tryAlloc(30); 
tryAlloc(40); 
tryAlloc(50); 
tryAlloc(100);

php-56-centos7:

real	0m0.659s
user	0m0.031s
sys	0m0.324s

php-70-centos7:

real	0m0.136s
user	0m0.039s
sys	0m0.082s

php 5.4 (openshift 2):

real	0m0.244s 
user	0m0.056s 
sys	0m0.179s

PHP 7.0 (centos 7 own docker image):

real	0m0.057s
user	0m0.029s
sys	0m0.028s

The different versions make it a bit hard to do comparisons but it's obviously noticeable that the S2I images are effecting performance. I ran these tests on the exact same hardware configuration.

@bparees
Copy link
Collaborator

bparees commented Dec 20, 2016

can you share the dockerfile for the php7-centos image you built?

I take it you're just running "docker run -it sometime /bin/sh" and then running your time php operation?

@andrewklau
Copy link
Contributor Author

The php7-centos image uses Remi's RPMs rather than the SCL https://raw.githubusercontent.com/andrewklau/docker-centos-lamp/master/Dockerfile

The S2I images were tested with both docker run -it xyz /bin/bash and also from the resultant image with the cakephp example

@hhorak
Copy link
Member

hhorak commented Dec 20, 2016

@andrewklau Do you also see performance differences between different php56 images, like whether it can be caused by changes in the latest build?

@hhorak
Copy link
Member

hhorak commented Dec 20, 2016

@remicollet FYI

@remicollet
Copy link
Contributor

PHP 7.0 is much faster, and use less memory than PHP 5.6, this is expected. this is even one of the most important PHP 7 change.

@andrewklau
Copy link
Contributor Author

@hhorak this has happened for quite some time (a few months)

@remicollet yeah, however 5.5 seems to perform better than 5.6

@andrewklau
Copy link
Contributor Author

andrewklau commented Dec 20, 2016

Here's another test, using the exact same deploymentconfig

<?php

$mark = microtime(true);

$a = 0; 
// CPU stress test 
for($i = 0; $i < 100000000; $i++) { 
$a += $i; 
}

echo "CPU Test: " . sprintf("%f", microtime(true)-$mark) . "\n";

centos-lamp (php 7.0 remi)

sh-4.2# time php test.php                                                                                                                                                                                                        
CPU Test: 5.598732                                                                                                                                                                                                               
                                                                                                                                                                                                                                 
real    0m5.653s                                                                                                                                                                                                                 
user    0m1.445s                                                                                                                                                                                                                 
sys     0m0.010s   

php-56-centos7

sh-4.2$ time php test.php                                                                                                                                                                                                        
CPU Test: 27.610644                                                                                                                                                                                                              
                                                                                                                                                                                                                                 
real    0m27.692s                                                                                                                                                                                                                
user    0m7.083s                                                                                                                                                                                                                 
sys     0m0.012s                                                                                                                                                                                                                 

@remicollet
Copy link
Contributor

remicollet commented Dec 20, 2016

Please compare enabled extensions (output of php -m)

E.g. some extensions, like XDebug could have performance impact.
Remi's packages also take benefit or recent changes in recent versions (dtrace is no more enabled by default in 7.0.14)

@andrewklau
Copy link
Contributor Author

andrewklau commented Dec 20, 2016

Ah!! Sorry the above results were centos-lamp and php-56-centos7

I believe php -m has found our culprit:

PHP55 does not have XDebug enabled
PHP56 does has XDebug enabled
PHP70 does not have XDebug enabled

I believe this would be related to #122

@andrewklau
Copy link
Contributor Author

andrewklau commented Dec 20, 2016

PHP 55/70

[Zend Modules]                                                                                                                                                                                                                   
Zend OPcache   

PHP 56

[Zend Modules]                                                                                                                                                                                                                   
Xdebug                                                                                                                                                                                                                           
Zend OPcache                                                                                                                                                                                                                     

Only php56 has xdebug being explicitly installed.

@alexvaa
Copy link

alexvaa commented Mar 29, 2018

I have a similar problem with 55 and 56 performance cpu
Did deleting xdebug help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants