Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

as the title says i am pretty puzzled here as to why would the first(Linode) server beat the pretty well-known liquid-web dedicated server by 40-50miliseconds(averaging 10ms to complete vs 50-60ms on dedicated) in a php script which uses dozen of mysql functions.

I did a loop test to meassure this.

Linode vps has 512MB ram vs 4gb on dedicatedbut i guess it shouldnt matter here.

Also, my vps on linode was loaded during tests averaging 10-20 requests per sec.

All of this makes me pretty worried to even transfer my site here which require fast mysql operations/tasks.

Any ideas or suggestions?

edit: Did one more test, a simple insert averages 30 miliseconds! I am puzzled completely.

Testing with

<?php

$started_at = millitime();

$user = "x";
$password = "x";
$database = "x";
mysql_connect('localhost', $user, $password) or die("Unable to conn");
mysql_select_db($database) or die("Unable to select database");


$result = mysql_query("INSERT INTO x VALUES ('','1', '1', '1')"); 


$ended = millitime();
$waited = $ended - $started_at;
echo "\n\n - >>> SCRIPT ENDED IN > " . $waited . "\n";



function millitime()
{
    $microtime = microtime();
    $comps = explode(' ', $microtime);
    // Note: Using a string here to prevent loss of precision
    // in case of "overflow" (PHP converts it to a double)
    return sprintf('%d%03d', $comps[1], $comps[0] * 1000) . "\n";
}



?>
share|improve this question
add comment

2 Answers

Linode vps has 512MB ram vs 4gb on dedicatedbut i guess it shouldnt matter here.

Databases are normally I bound, memory helps.

Any ideas or suggestions?

Do not bother with CPU unless you are CPU bound. Figure out cache use (memory) and IOPS. Databases live and die by IO performance most of the time, the CPU rarely even being bothered.

share|improve this answer
    
Hi TomTom, thanks for your help but can you be bit more specific as to what can i change/look about here? –  Marko29 Feb 22 '13 at 8:14
    
Lantecy, doing an IOPS throughput test via disc based performance tests. Generally a sensible IOPS test. –  TomTom Feb 22 '13 at 9:18
    
It seems if i change the table to MyISAM its completely another story and inserts and other query averages on 0. milisecond while on the vps server innoDB is perhaps even faster then MyISAM but still both of them work fast unlike on the dedicated server where InnoDB performs terrible –  Marko29 Feb 23 '13 at 22:33
add comment

Did one more test, a simple insert averages 30 miliseconds! I am puzzled completely.

That seems about right. You need at least two rotations to perform a database update. Say your disks spin at 5400 RPM. That gives: (60*1000*2)/5400 = 22ms minimum.

Of course, the system can do plenty of other things while that insert is taking place. You're just waiting for I/O to complete.

share|improve this answer
    
On the much weaker vps it takes 0 or 1 ms, completely same test script then how is it right? –  Marko29 Feb 22 '13 at 8:46
    
The VPS probably has some reliable backing store other than rotating media. For example, if you have two storage servers, you can consider a write committed as soon as one of them acknowledges the write without having to wait for any rotating media. Or if you have a disk with a battery-backed RAM cache, you can consider the write committed once it's in that battery-backed RAM. –  David Schwartz Feb 22 '13 at 8:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.