Page 1 of 1

Slow PHP performance gengeneral

Posted: Wed Mar 16, 2016 1:33 pm
by andr2884
Hello,

when i only call

Code: Select all

/usr/local/zendsvr6/bin/php -r 'echo "test";'
or

Code: Select all

/usr/local/zendsvr6/bin/php -r 'echo "test";'
it takes up to 4 seconds to get a response.

I figured out, the problem is in the php.ini

Code: Select all

zend.ini_scandir=conf.d
In the directory /usr/local/zendsvr6/etc/conf.d, there are a lot of config files which are loaded each time.

Code: Select all

bcmath.ini                      pagecache.ini
bz2.ini                         pcntl.ini    
calendar.ini                    pdo_dblib.ini
codetracing.ini                 pdo_ibm.ini  
datacache.ini                   pdo_mysql.ini
debugger.ini                    pdo_pgsql.ini     
deployment.ini                  pgsql.ini         
exif.ini                        phar.ini          
fileinfo.ini                    posix.ini         
gd.ini                          pspell.ini        
gettext.ini                     redis.ini         
gmp.ini                         shmop.ini         
ibm_db2.ini                     sockets.ini       
iconv.ini                       ssh2.ini          
imagick.ini                     statistics_ext.ini
imap.ini                        statistics.ini    
intl.ini                        sysvmsg.ini       
jbridge.ini                     sysvsem.ini       
jobqueue.ini                    sysvshm.ini       
ldap.ini                        tidy.ini                  
loader.ini                      tokenizer.ini             
mbstring.ini                    url_insight.ini           
mcrypt.ini                      utils.ini                 
memcache.ini                    wddx.ini                  
monitor_ui.ini                  xmlrpc.ini                
monitor.ini                     xmlwriter.ini             
mssql.ini                       xsl.ini                   
mysql.ini                       zend_extension_manager.ini
mysqli.ini                      zf2.ini                   
oci8.ini                        zip.ini                   
odbc.ini                        zray.ini                  
opcache.ini                     ZendGlobalDirectives.ini
If i disable this config entry, i get immediately a response.
Also if i just disable some of them the performance is not as good as if i disable all but better than before.

In some there is a registration entry which needs to be loaded by the extension manager:

Code: Select all

; register the extension to be loaded by Zend Extension Manager
zend_extension_manager.dir.jobqueue=/usr/local/zendsvr6/lib/jobqueue
If i comment it out, performance is better.

Does any one know why the performance is that bad?
Is there anything i need to do? (Except of disabling all the configs)

Thanks!
Andreas

Re: Slow PHP performance gengeneral

Posted: Thu Mar 17, 2016 10:04 am
by erich_hieden
To be honest I haven't looked into why the performance is bad. But instead I want to ask you, what you want to accomplish.

Just out of my experience I never had a problem with zendsvr nedding a few seconds to start since I will use CLI only for batch jobs where time isn't that important. Where time is important and I need PHP to do something I resort to a WebService-call, so I can use the already running HTTP zendsvr instance.

I know this is no direct answer to your question and I apologize for that. I just wanted to show you, that there are ways to circumvent your problem.

Best

Re: Slow PHP performance gengeneral

Posted: Thu Mar 17, 2016 2:20 pm
by scottgcampbell
The performance would be slow because it has to start an entire PHP stack. But could also be an under powered/old server. I did some tests on our dev and production servers

Code: Select all

 date;/usr/local/zendsvr6/bin/php-cli -r 'echo "test\n";';date 
Dev - 4 seconds

Code: Select all

Thu Mar 17 06:51:07 Mountain Daylight Time 2016  
test                                             
Thu Mar 17 06:51:11 Mountain Daylight Time 2016  
Production - over 1 second

Code: Select all

Thu Mar 17 06:51:36 Mountain Daylight Time 2016   
test                                              
Thu Mar 17 06:51:37 Mountain Daylight Time 2016   
This is an 8 year old Power 6+ with 3 Lpars, the dev is tiny with only .25 of one processor and 2Gb of memory, the production server only has 1 processor and only 9Gb of memory.

Is is possible you have an old/small machine or one that is extremely busy?

Either way PHP from the command line will ALWAYS have some startup time since it has to do just that, start everything up to process your request, it is not accessing the running PHP processes.

Testing using wget on the SLOW machine:

Code: Select all

date;wget http://localhost/test.php;date; 
Less than 1 second:

Code: Select all

Thu Mar 17 07:18:32 Mountain Daylight Time 2016
--07:18:32--  http://localhost/test.php                              
           => `test.php.2'                                           
Resolving localhost... 127.0.0.1                                     
Connecting to localhost[127.0.0.1]:80... connected.                  
HTTP request sent, awaiting response... 200 OK                       
Length: unspecified [text/html]                      
    [ <=>                                 ] 1             --.--K/s   
07:18:32 (9.77 KB/s) - `test.php.2' saved [1]    
Thu Mar 17 07:18:32 Mountain Daylight Time 2016   
Most likely unless you have batch processing (as mentioned) and you aren't worried about the startup time you will want to find an alternative method to the php cli.

Scott

Re: Slow PHP performance gengeneral

Posted: Mon Mar 21, 2016 3:29 pm
by andr2884
Thanks for your answers.
Our machine is a very strong one.

On our test system (which is much slower than the production) we have the same performance.
When i have enabled the configs described above it takes a long time to set up the php environment

Code: Select all

php -version
PHP 5.6.18 (cli) (built: Feb  8 2016 16:05:06)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend Extension Manager v8.5.0, Copyright (c) 2003-2015, by Zend Technologies
    - with Zend Data Cache v8.5.0, Copyright (c) 2004-2015, by Zend Technologies [loaded] [licensed] [disabled]
    - with Zend Guard Loader v3.3, Copyright (c) 1998-2015, by Zend Technologies [loaded] [licensed] [enabled]
    - with Zend Java Bridge v8.5.0, Copyright (c) 2004-2015, by Zend Technologies [loaded] [licensed] [enabled]
    - with Zend Job Queue v8.5.0, Copyright (c) 2004-2015, by Zend Technologies [loaded] [licensed] [disabled]
    - with Zend Utils v8.5.0, Copyright (c) 2004-2015, by Zend Technologies [loaded] [licensed] [enabled]
    - with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies [loaded] [licensed] [enabled]
    - with Zend Code Tracing v8.5.0, Copyright (c) 2009-2015, by Zend Technologies [loaded] [not licensed] [disabled]
    - with Zend Server Z-Ray v8.5.0, Copyright (c) 1999-2015, by Zend Technologies [loaded] [not licensed] [disabled]
    - with Zend Monitor v8.5.0, Copyright (c) 1999-2015, by Zend Technologies [loaded] [licensed] [disabled]
    - with Zend Debugger v6.0.0-i5, Copyright (c) 1999-2015, by Zend Technologies [loaded] [licensed] [enabled]
    - with Zend Page Cache v8.5.0, Copyright (c) 2004-2015, by Zend Technologies [loaded] [licensed] [disabled]
    - with Zend Monitor UI v8.5.0, Copyright (c) 2004-2015, by Zend Technologies [loaded] [licensed] [enabled]
If i have disabled it, it's very fast.

Code: Select all

php -version
PHP 5.6.18 (cli) (built: Feb  8 2016 16:05:06)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend Extension Manager v8.5.0, Copyright (c) 2003-2015, by Zend Technologies

Re: Slow PHP performance gengeneral

Posted: Fri Jun 10, 2016 2:56 am
by aseiden
When you use PHP-CLI (command line PHP), you're starting PHP and all its extensions from scratch. The extensions loaded by PHP.INI are what takes the time. Disable the extensions you don't need. That's the answer. Use a custom PHP.INI file if you like.

Regular web-based FastCGI PHP is pre-started and much faster, even with extensions.

--Alan
Alan Seiden Consulting