I'm having some issues with a site I just recently moved over to a 4GB Linode. The Linode is running Ubuntu 13.10 (GNU/Linux 3.11.6-x86_64-linode35 x86_64), and the site runs on Apache/2.4.6 with PHP 5.5.3-1ubuntu2.1. The site has basically no traffic at this point, so these results are measuring one visitor, not under load.
There are a few pages that take a very long time to load. The site is built on PHP using ExpressionEngine, and I'm using the CodeIgniter profiler to measure rendering times. Note that the CI profiler just measures PHP server-side execution times, and that's where the problem is, nothing client-side.
On my Linode, the page takes over 6s to render:
Code:
Loading Time: Base Classes 0.0064
Controller Execution Time ( Ee / Index ) 6.2166
Total Execution Time 6.2233
On my MacBook local dev running MAMP 2.2 with PHP 5.5.3, with exactly the same codebase and database, this page takes just 1s to render:
Code:
Loading Time: Base Classes 0.0194
Controller Execution Time ( Ee / Index ) 1.0952
Total Execution Time 1.1148
Note that I also have a preview site running on a crappy $5/mo 1&1 shared server, which also renders the page in about 1 second.
At first I thought MySQL config could be the culprit because the page runs a lot of SQL queries, but looking at the profiler, on my local only about 0.2s is spent on SQL queries, and on the Linode only about 0.6s is spent (measured from PHP, so it includes latency). This means a good 5.5s is being spent just on running PHP while not waiting for the database.
I downloaded a basic PHP benchmark script from
http://www.php-benchmark-script.com/ and ran it on the Linode and on my local MacBook. Here are the results from the Linode:
Code:
--------------------------------------
| PHP BENCHMARK SCRIPT |
--------------------------------------
Start : 2013-12-15 15:17:15
Server : @
PHP version : 5.5.3-1ubuntu2.1
Platform : Linux
--------------------------------------
test_math : 19.591 sec.
test_stringmanipulation : 17.819 sec.
test_loops : 9.298 sec.
test_ifelse : 7.727 sec.
--------------------------------------
Total time: : 54.435 sec.
And here are the results from the MacBook:
Code:
--------------------------------------
| PHP BENCHMARK SCRIPT |
--------------------------------------
Start : 2013-12-15 16:19:11
Server : localdev.thediamethod.com@127.0.0.1
PHP version : 5.5.3
Platform : Darwin
--------------------------------------
test_math : 3.431 sec.
test_stringmanipulation : 4.209 sec.
test_loops : 2.755 sec.
test_ifelse : 1.786 sec.
--------------------------------------
Total time: : 12.181 sec.
So my question is: why is PHP 5x slower on my Linode than on my MacBook or my 1&1 shared server, and is there any way to speed it up?