Thursday 28 April 2016

Does output buffering in PHP require more resources?



When performance is important including server memory,I am curious if using output buffering
like ob_start(); in PHP has ANY performance hits over not using it? Does it use more memory or anything to use it?



In my situation on a high traffic site where I need all the memory I can for memcache and APC and all the other server activities I am just curious if I should use it or not, the only real reason it comes in handy for me is for redirecting pages , sending headers I should say after a header has already been sent, my site has header , body, footer file setup so sometime I need to redirect depending on what is in the body file so if the header is already shown ion screen that creates a problem, using output buffering is 1 solution but there are other solutions so just curious about performance



Answer



I think it's best to use it with a high traffic site, or at least turn implicit flush off, to avoid sending partial responses over network, because it can slow down the rest of the script if the receiver is very slow too.



By sending the whole response in one time, you free all resources used by the php script, so it's more efficient.


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...