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?

T.Todua
  • 204
  • 4
  • 14
  • 2
    Yes, there will be a significant difference. Php is slow like hell. – Ipor Sircer Aug 29 '16 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? – Julie Pelletier Aug 29 '16 at 22:37
  • thanks for response. I will try `top`. Also, I have found this topic too: http://www.tecmint.com/command-line-tools-to-monitor-linux-performance/ – T.Todua Aug 30 '16 at 08:04
  • Obvious is to simply measure... – HBruijn Aug 31 '16 at 20:16

1 Answers1

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.

Ryan Babchishin
  • 6,160
  • 2
  • 16
  • 36