Reputation: 21
I'm going to "read" (video/big) files from a server (shared environment) to clients (webbrowsers) via PHP and would like to know first if there is a way to reduce CPU and RAM usage somehow (as I have those limited).
Upvotes: 2
Views: 1448
Reputation: 1532
Basically, it depends on how busy your site will be. If you site will be rarely visited then you can fake stream this way, however it has a very high cpu load. Any kind of large file stream/read is best performed on a seperate server to your webserver. ie use a cdn or additional server to serve video files, like for example nginx
Upvotes: 0
Reputation: 449395
if there is a way to reduce cpu and ram usage somehow
Not really: You'd just have to stream the video through (using fread()
in small chunks) instead of reading it into memory in full. There is little space for optimization both on the RAM and the CPU end here.
That said, it is not very good on performance to stream video through PHP, and as I've already said today in a similar question, if I were a server administrator, I would frown upon that kind of activity. If at all possible, you really should consider using a normal download, or specialized streaming server for this.
Upvotes: 4