Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Sun Dec 15, 2013 11:41 am 
Offline
Senior Newbie

Joined: Sun Dec 15, 2013 11:21 am
Posts: 5
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?


Top
   
PostPosted: Sun Dec 15, 2013 2:12 pm 
Offline
Senior Member

Joined: Sun May 23, 2010 1:57 pm
Posts: 315
Website: http://www.jebblue.net
I'm not really a PHP person but I Googled some and put the PHP CLI script below together, it runs on my home machine in around .37 seconds and on my Linode around .11 seconds:

Code:
#!/usr/bin/php

<?php

$time = microtime(TRUE);
$mem = memory_get_usage();

# START the code to speed test
for ($x=0; $x<=10000; $x++)
{
  echo "The number is: $x\n";
}
# END the code to speed test

print_r(array(

  'memory' => (memory_get_usage() - $mem) / (1024 * 1024),

  'seconds' => microtime(TRUE) - $time

));

?>


Here's my home machine spec, 8 cores:

vendor_id : GenuineIntel
cpu family : 6
model : 58
model name : Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
stepping : 9

Here's my Linode:

vendor_id : GenuineIntel
cpu family : 6
model : 26
model name : Intel(R) Xeon(R) CPU L5520 @ 2.27GHz
stepping : 5

How fast does your Linode run the above?


Top
   
PostPosted: Sun Dec 15, 2013 6:00 pm 
Offline
Senior Newbie

Joined: Sun Dec 15, 2013 11:21 am
Posts: 5
Hi jebblue, thanks for your reply. Your CLI script runs on my Linode in 0.27 seconds and on my local MacBook in 0.05 seconds.


Top
   
PostPosted: Sun Dec 15, 2013 9:45 pm 
Offline
Senior Member

Joined: Sun May 23, 2010 1:57 pm
Posts: 315
Website: http://www.jebblue.net
wtravish wrote:
Hi jebblue, thanks for your reply. Your CLI script runs on my Linode in 0.27 seconds and on my local MacBook in 0.05 seconds.


Seems hard to believe a macbook could beat my fast home machine running Linux.

EDIT: I just tried it on my laptop and I get .05. Weird, seems like my desktop would have beaten it, or that's what I'd have thought.


Last edited by jebblue on Mon Dec 16, 2013 12:07 am, edited 1 time in total.

Top
   
PostPosted: Mon Dec 16, 2013 12:03 am 
Offline
Senior Newbie

Joined: Tue Jun 07, 2011 5:25 pm
Posts: 14
Just for reference, my Linode took .23 and my MacBook Air took .03.

Removing the echo statement changes the times to .0012 for the Linode and .0003 for the MacBook Air.

Removing the SSH overhead for the echo responses does make a difference.

Dave Sand


Top
   
PostPosted: Mon Dec 16, 2013 12:10 am 
Offline
Senior Member

Joined: Sun May 23, 2010 1:57 pm
Posts: 315
Website: http://www.jebblue.net
dasand wrote:
Just for reference, my Linode took .23 and my MacBook Air took .03.

Removing the echo statement changes the times to .0012 for the Linode and .0003 for the MacBook Air.

Removing the SSH overhead for the echo responses does make a difference.

Dave Sand


Wow, so I ssh'ed into my laptop and got .05 then ssh'ed back to my desktop and run it and I get .05? When I just open the terminal on my desktop directly and run it it's slow at .37.


Top
   
PostPosted: Mon Dec 16, 2013 12:19 am 
Offline
Senior Newbie

Joined: Tue Sep 24, 2013 11:14 am
Posts: 5
Location: India
Making use of php 5.5's opcache might help

http://php.net/opcache


Top
   
PostPosted: Mon Dec 16, 2013 12:37 pm 
Offline
Senior Newbie

Joined: Sun Dec 15, 2013 11:21 am
Posts: 5
I enabled the OpCache, but it doesn't seem to have made any difference in this case. I actually think it's enabled by default in 5.5, so I might have already been getting the benefit of that.


Top
   
PostPosted: Mon Dec 16, 2013 1:48 pm 
Offline
Senior Member
User avatar

Joined: Tue May 26, 2009 3:29 pm
Posts: 1691
Location: Montreal, QC
Perhaps you might contact Linode support to see if there are any performance issues on the host?


Top
   
PostPosted: Mon Dec 16, 2013 2:35 pm 
Offline
Senior Newbie

Joined: Sun Dec 15, 2013 11:21 am
Posts: 5
I've actually done that as well, but they didn't see any performance issues on the host. I've migrated to a different VPS instance, but it didn't make a difference.


Top
   
PostPosted: Wed Dec 18, 2013 7:44 pm 
Offline
Newbie

Joined: Tue Oct 15, 2013 3:41 pm
Posts: 4
Can you provide access to a phpinfo()? I'm assuming a configuration issue. My linodes are completing the php benchmark script in < 18 seconds. I also have a couple of FuelCMS/CI sites running on one VPS with zero issues. Page loads are instant.

Also, just putting it out there, it's semi ridiculous to compare the processing time between a VPS and a local local machine..


Top
   
PostPosted: Thu Dec 19, 2013 10:02 pm 
Offline
Senior Newbie

Joined: Sun Dec 15, 2013 11:21 am
Posts: 5
I'm hoping it's a configuration issue. Here's a link to the full PHPInfo: http://thediamethod.com/info.php

I also agree that it's somewhat silly to compare to a local machine, although I'm also seeing much better performance on a shared hosting service. If it just turns out that a VPS is 10x slower than a shared host, so be it. It does seem somewhat fishy though.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group