This pair of scripts shows what I mean:
client (JS)
$.ping = function(i_max) {
$.get('ping.php', {
'i_max': i_max,
'client_start': Date.now() / 1000
}).done(function(d){
console.log(d);
})
}
server (PHP)
$client_start = $_GET['client_start'];
$server_start = round(microtime(true) * 1000) / 1000;
$diff = $server_start - $client_start;
$i = 0;
$i_max = $_GET['i_max'];
while($i < $i_max) {
sleep(1);
$i++;
}
echo "i_max = $i_max => diff = $diff\n";
When few instances are run latency is good, beyond, latency goes bad, is there an option to set in php.ini? Here is a console screenshot: