Reputation: 21
I have a problem here, maybe someone has already gone through this before.
A system controller is serving php downloads, it reads information from files and sends the client as a download. The system works perfectly. The problem is that speed is always low, always less than the 300kb/se times less than 100kb / s for the user.
The server has a 100mbps link 6mbps free and the customer has, then it should be downloaded at 600kb / s. Something is holding the output of php. I've tried searching on the buffers of apache but found nothing on this issue.
Does anyone have any idea what might be happening?
Upvotes: 2
Views: 132
Reputation: 283
PHP really isn't built for processing large files. It has to read that entire file into memory and then output it. It sounds like you're sending a reasonable amount of traffic through PHP, if 100kb/s - 300kb/s per user is too slow, via something like readfile()
which is a bad idea. Instead, I suggest taking a look at mod_xsendfile
(if you're using Apache) or it's equivalent for your web server of choice (e.g. I prefer nginx, and would use XSendFile
for this).
In PHP then, you can just do this: header('X-Sendfile: ' . $file);
. The server intercepts the header, and sends that file. It allows you the benefits of what you're doing with PHP, and the speed of the web server directly reading the file.
Upvotes: 6