We have a Facebook application and we are trying to move to Azure cloud hosting. We've opened two hosted services, one for the MySQL database and the other for our Web application. On each service we've deployed a Virtual Machine.
On the machine of the Web Application we use PHP 5.3.14 with Apache 2.4.2 and on the database machine we use Apache 2.4.2, PHP 5.3.14 and MySQL 5.5.25.
Both machines are Windows Server 2008 R2 SP1.
We have a preformance problem between the two Azure Hosted service. For preformance testing, we run this simple PHP script that is located both on the database machine and on the Web application machine. This is simply querying and returning the current time
for 4000 times:
<?php
$serverInfoArray = array("host" => HOST, "user" => USER, "pass" => PASS);
//Create connection to server//
$connectionFB = mysql_connect($serverInfoArray["host"], $serverInfoArray["user"], $serverInfoArray["pass"]);
//Select database//
mysql_select_db(DBNAME_FB_NEW, $connectionFB);
mysql_query("set names utf8", $connectionFB); //For hebrew support//
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
for($i=0; $i < 4000; $i++)
{
$result = mysql_query("SELECT NOW()");
$array = mysql_fetch_assoc($result);
echo $array['NOW()'];
echo "<br>";
}
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round(($finish - $start), 4);
echo 'Page generated in '.$total_time.' seconds.';
?>
When we are accessing this script from inside the database machine into itself (Host = localhost) then this script takes less then a second to finish (usually +-0.7sec).
But, When we try to access this script from our Web Application machine to our Database machine (Host = IPofDataBaseMachine), this scripts takes more than 5 seconds to finish !
It seems that Azure has a problem when one service is trying to receive info from another service (The low performance only happens when we query the database from the PHP script that is located on the web application service).
We haven't found any documentation about it, and I want to ask if any of you experienced similar problem, has an idea about what can cause this kind of performance problem.
Thanks
Best Answer
If we assume that there is a network latency between virtual machines (e.g. 1ms) than your 4000 roundtrips to the database easily add up to several seconds. This is not unusual.
You can look at different blogs (e.g. here) to see what other people experience in terms of latency in Azure.