I'm going to "read" (video/big) files from a server (shared environment) to clients (webbrowsers) via PHP and would like to know fi开发者_开发技巧rst if there is a way to reduce CPU and RAM usage somehow (as I have those limited).
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.
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
精彩评论