Outputting File To The Browser Failed And Kill Apache

From: Date: Fri, 05 Jun 2009 19:52:39 +0000
Subject: Outputting File To The Browser Failed And Kill Apache
Groups: php.general 
Request: Send a blank email to php-general+get-293682@lists.php.net to get a copy of this message
Hi List, I'm using the following code to output a file to the browser. Each file size is in the range of 5-10MB, all of them are MP3. header("Pragma: public"); > header("Expires: 0"); > header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); > header("Cache-Control: public"); > header("Content-Description: File Transfer"); > header("Content-Type: {$info['mimetype']}"); > header("Content-Disposition: attachment; > filename=\"{$info['filename']}\""); > header("Content-Transfer-Encoding: binary"); > header("Content-Length: " . $info['size']); > > set_time_limit(0); > > $file = > > @fopen($config['storage'][$config['current_storage']].$info['md5'].".".$info['extension'],"rb"); > if ($file) { > while(!feof($file)) { > print(fread($file, 1024*8)); > flush(); > if (connection_status()!=0) { > @fclose($file); > die(); > } > } > @fclose($file); > } I'm running this script on a VPS which has a 10MBIT connection. When I posted a link to this download stream php file about 50 users started download it, then the script stopped from sending the whole file (for instance, the file is 5MB, the script sends 2MB, 1MB and it continue this way). In the apache log file I have seen these lines, but I have no idea what are their meaning: [Fri Jun 05 22:02:28 2009] [error] (12)Cannot allocate memory: fork: Unable > to fork new process > [Fri Jun 05 22:02:38 2009] [error] (12)Cannot allocate memory: fork: Unable > to fork new process > [Fri Jun 05 22:02:48 2009] [error] (12)Cannot allocate memory: fork: Unable > to fork new process > [Fri Jun 05 22:11:35 2009] [error] (12)Cannot allocate memory: fork: Unable > to fork new process > I have no idea what's going on. Any ideas to solve this issue will be very appreciated. My 12K users are suffering right now, I would really really appreciate any idea in the right direction :) :) :) Thank you!

« previous php.general (#293682) next »