My setup: - nginx 1.0.6 ( compiled from scratch ) - php 5.3.8 with php-fpm ( also from scratch ).
I use this PHP script to stream files from the remote site to my users:
$chunksize = 1 * (1024 * 1024); //you may want to change this
$bytes_send = 0;
if ($file = fopen($file, 'rb',false)) {
while(!feof($file) && (!connection_aborted()) && ($bytes_send<$new_length)) {
$buffer = fread($file, $chunksize);
echo ($buffer);
flush();
$bytes_send += strlen($buffer);
}
fclose($file);
} else {
die('Error - can not open file.');
}
after i start to download with my connection ( 20 Mbps ) , i've got such result of ifstat
eth0
KB/s in KB/s out
5105.77 1925.70
5106.15 2063.77
5083.80 2337.95
4946.52 2487.28
5127.37 2507.15
5118.94 2474.98
5172.55 2438.86
4646.82 2451.87
5246.18 2465.98
5186.71 2459.66
5032.03 2458.55
Is that normal? The result on the production server was a complete failure because of lack of bandwidth :| on apache the balance is even. Help really appreciated : /
@Edit Little benchmark made. Downloading 500 MB file via this. Results for about 250-260 MBs were just like that and then in gone down to almost 0. Is that some kind of network usage balance nginx does?