High CPU usage when streaming a file
Posted: Tue Oct 09, 2007 5:50 am
Hi,
I have a web application that allows users to download pdf files from the server. To control access to these files they are not in a directory that is visible from the web. When a user requests one of the files the code sets the necessary headers and writes the files bytes to the output. Using
The problem is that when this occurs there is a peak in the CPU usage of the server which can (momentarily) go as far up as 100%.
I have tried other methods of streaming the file such as
But the result is the same.
How can i control these peaks in the CPU usage? Any comments welcome.
max
I have a web application that allows users to download pdf files from the server. To control access to these files they are not in a directory that is visible from the web. When a user requests one of the files the code sets the necessary headers and writes the files bytes to the output. Using
Code: Select all
fpassthru($file);
flush();The problem is that when this occurs there is a peak in the CPU usage of the server which can (momentarily) go as far up as 100%.
I have tried other methods of streaming the file such as
Code: Select all
while(!feof($file)) {
print(fread($file, 1024*8));
flush();
}But the result is the same.
How can i control these peaks in the CPU usage? Any comments welcome.
max