I have youtube video proxy service which uses following code:
<?php
set_time_limit(0);
if(isset($_GET['videoURL']) && $_GET['videoURL']!=''){
$URL=$_GET['videoURL'];
$URL=base64_decode($URL);
$video = @fopen($URL, "rb");
// Forward headers, $http_response_header is populated by fopen call
foreach ($http_response_header AS $header) {
header($header);
}
// Output contents of flv
while (!@feof($video)) {
print (@fgets($video));
}
fclose($video);
}
?>
but the issue is, it ads huge server load killing server several times. Suddenly CPU peaks and slows down to limit that we have to restart. This happens for less than 30 users.
Here is the info I got from WHM panel::
Server load 77 (2 CPUs)
Memory Used 63.36% (1,216,536 of 1,920,036)
Swap Used 97.54% (1,022,776 of 1,048,568)
Almost swap is full and server is showing load at warning level.
I hosted same script at digitalocean and now at photonvps but issue persists.