How to check the upload and download speeds of my server?

I bought a server, and I need to check its Internet connection (speed).

Is there an easy way to do this?

I googled but found nothing ...

I have done this:

<?php

$link = 'http://speed.bezeqint.net/big.zip';
$start = time();
$size = filesize($link);
$file = file_get_contents($link);
$end = time();

$time = $end - $start;

$speed = $size / $time;

echo "Server speed is: $speed MB/s";


?>

Is it correct?

+5
source share
4 answers

Try:

<?php

$link = 'http://speed.bezeqint.net/big.zip';
$start = time();
$size = filesize($link);
$file = file_get_contents($link);
$end = time();

$time = $end - $start;

$size = $size / 1048576;

$speed = $size / $time;

echo "Server speed is: $speed MB/s";


?>
+9
source

If you have a remote desktop, then install a web browser and go to speedtest.net and check the speed.

If not, how can you test the download speed of your server:

  • log in as root
  • type wget http://cachefly.cachefly.net/100mb.test
  • you will see something like 100%[======================================>] 104,857,600 10.7M/s- 10.7M / s - download speed.

If you have more than one server, you can check the download speed by transferring files between the two servers.

+5

, , , (, Google). , - . - . .

:

$times = Array(microtime(true));
$f = fsockopen("google.com",80);
$times[] = microtime(true);
$data = "POST / HTTP/1.0\r\n"
       ."Host: google.com\r\n"
       ."\r\n"
       .str_repeat("a",1000000); // send one megabyte of data
$sent = strlen($data);
fputs($f,$data);
$firstpacket = true;
$return = 0;
while(!feof($f)) {
    $return += strlen(fgets($f));
    if( $firstpacket) {
        $firstpacket = false;
        $times[] = microtime(true);
    }
}
$times[] = microtime(true);
fclose($f);
echo "RESULTS:\n"
    ."Connection: ".(($times[1]-$times[0])*1000)."ms\n"
    ."Upload: ".number_format($sent)." bytes in ".(($times[2]-$times[1]))."s (".($sent/($times[2]-$times[1])/1024)."kb/s)\n"
    ."Download: ".number_format($return)." bytes in ".(($times[3]-$times[2]))."s (".($return/($times[3]-$times[2])/1024)."kb/s)\n";

( Google, - Content-Length)

, , , , Google .

+2

script, :

$start = time(true);

$fileSize = '10240'; // if the file size is 10MB

for ($i=0; $i<10; $i++) {
    file_get_contents('the_url_of_a_pretty_big_file');
}

$end = time(true);

$speed = ($fileSize / ($end - $start)) / $i * 8;

echo $speed; // will return the speed in kbps
0

All Articles