Welcome to WebmasterWorld Guest from 54.145.117.60

Forum Moderators: Ocean10000 & incrediBILL & phranque

Fastest PHP Handler?

     
1:18 am on Oct 8, 2017 (gmt 0)

Junior Member

10+ Year Member

joined:May 20, 2006
posts: 73
votes: 0


I'm currently running a VPS server (Prefork and DSO+modruid2 by default set by the web host) with EA4, CentOS 7.4, and cPanel 66, with 1.2GB of RAM but with equal-shared 16-core CPU available so there's plenty of CPU power.

It's low traffic so memory use is OK as I'm getting between 40-60% utilization on average. And I don't experience OOM errors so far.

In preparation for using the now stable HTTP/2 module, I plan to use MPM Event and either PHP-FPM or CGI since DSO can no longer be used.

My first step is to first change the PHP handler to something other than DSO. Since only CGI and PHP-FPM is available on the server, I made a benchmark using a Wordpress plugin that tests MySQL and PHP performance and below were the results:

===
PHP 5.6 using DSO
MySQL - 11.33 seconds
PHP - 4.16s

PHP 5.6 using PHP-FPM
MySQL - 10.96s
PHP - 3.60s

PHP 7.0 using CGI
MySQL - 11.28s
PHP - 1.38s

PHP 7.0 using PHP-FPM
MySQL - 11.57s
PHP - 1.42s
===

On PHP 7.0, CGI appeared to be slightly faster than PHP-FPM. I believe this CGI is not FastCGI (since factcgi cannot be utilized on multi-php environment).

I heard in some forums that php-fpm is the fastest handler. But are there cases where CGI can be a bit faster than PHP-FPM under default configuration ? Because if that is the case, I will utilize MPM Event + CGI sitewide in preparation to HTTP/2.
2:27 am on Oct 8, 2017 (gmt 0)

Moderator from US 

WebmasterWorld Administrator keyplyr is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Sept 26, 2001
posts:10114
votes: 550



As you have determined, DSO (mod_php) is slow. It's one of the oldest.

Have you tried FCGI (FastCGI)? It seems to get good performance reviews and offers opcode caching.
4:55 am on Oct 8, 2017 (gmt 0)

Junior Member

10+ Year Member

joined:May 20, 2006
posts: 73
votes: 0


I haven't tried FCGI since it isn't installed on my server and I think PHP-FPM is based on fcgi anyway.

Since my only choice is either CGI or PHP-FPM if I move to MPM Event, would you recommend the older CGI if my benchmark shows it is faster on the server, or do you recommend I'd just go to the newer PHP-FPM?
11:18 am on Oct 8, 2017 (gmt 0)

Moderator from US 

WebmasterWorld Administrator keyplyr is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Sept 26, 2001
posts:10114
votes: 550


I had periodic problems with earlier versions of php run as cgi. 7 may have resolved this.
4:09 pm on Oct 8, 2017 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Sept 25, 2005
posts:1569
votes: 213


I don't think a WordPress benchmark is particularly representative of the performance of the PHP gateway. It's probably just a single timed script, not what you would normally run. 1.42s is only a <3% increase over 1.38s, a negligible difference, and if you repeat the benchmark it could very well be reversed. I would pick the software that is easiest to install, maintain and update. I use PHP-FPM myself and find it pretty easy to use.
12:39 am on Oct 9, 2017 (gmt 0)

Junior Member

10+ Year Member

joined:May 20, 2006
posts: 73
votes: 0


I did run the PHP benchmark a couple of times and it always ended the CGI to be a bit faster than PHP-FPM. You could be right that the benchmark plugin is not very well accurate.

Most likely I'll go to PHP-FPM since many people seems to recommend it more.

What is your recommended combination of Apache MPM for PHP-FPM that has the best compatibility with the http/2 module? Would an MPM Event + PHP-FPM a good combination compared to MPM Worker + PHP-FPM ?
7:26 am on Oct 9, 2017 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Sept 25, 2005
posts:1569
votes: 213


Sorry, can't help you there, I switched to nginx many years ago.
7:57 am on Oct 9, 2017 (gmt 0)

Senior Member from GB 

WebmasterWorld Senior Member brotherhood_of_lan is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 30, 2002
posts:4884
votes: 16


Also use NGINX but PHP-FPM in the background. Just a note to say if you choose PHP-FPM, consider which process manager to use (the 'pm' configuration option - see pm settings in manual [php.net...] ).

Most people just go for 'dynamic' as the value, but for a low-traffic server like you mention, you may be better off going with 'ondemand'. The difference is that 'ondemand' will kill idle PHP processes off rather than having them on all the time. Less CPU efficient but more memory efficient.

I've been using ondemand to reasonable effect on a single server hosting 400 Wordpress websites, each site using its own PHP pool and chrooted environment.
8:55 am on Oct 9, 2017 (gmt 0)

Junior Member

10+ Year Member

joined:May 20, 2006
posts: 73
votes: 0


I'm not comfortable with third-party scripts unfortunately, and I may need support from my webhost and cPanel from time to time.

Since my PHP-FPM package was installed in its default settings, I believe it is already set in 'ondemand' since that is its default settings according to the cPanel manual.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members