1

On one of my site, I have a large-file download method using:

site.com/downloader.php?file=MyLargeFile.mp3

then PHP file executes readfile to start file downloading.

Typically, not to go in details of load-balancing, I just wanted to know how PHP engine works - does such approach in PHP (throwing files usingreadfile, file_get_contents or etc...) take more CPU/Overload, compared to downloading with direct links, like site.com/MyLargeFile.mp3? Or PHP engine does same using those commands?

4
  • 2
    Yes, there will be a significant difference. Php is slow like hell. Aug 29, 2016 at 22:08
  • 2
    Contrary to the above comment and the answer received, I seriously doubt that such a script could cause your overload. It will obviously use more resources than a direct download but there is probably something else that's causing your issue. Did you check top or at the very least, your web server log? Aug 29, 2016 at 22:37
  • thanks for response. I will try top. Also, I have found this topic too: tecmint.com/command-line-tools-to-monitor-linux-performance
    – T.Todua
    Aug 30, 2016 at 8:04
  • Obvious is to simply measure...
    – HBruijn
    Aug 31, 2016 at 20:16

1 Answer 1

1

There's no way to know for sure without more information. You need to check and see what's causing the high CPU usage, not ask. The top command will probably be a good start. We need you to gather some info and show us your script too possibly if you need help with it.

Otherwise it's just a guess and my guess is: yes direct file access is less likely to impact server performance. But your script and web config could be fine. There's no way to know. The problem could be something completely different.

Not the answer you're looking for? Browse other questions tagged or ask your own question.