Php output buffering performance implications with Apache and MySQL

I am a bit confused about how php buffering works.

Say you have a php page foo.php and output_buffering = 4096 in php.ini , and Apache receives a receive request for foo.php . foo.php starts execution, and as soon as 4096 bytes are ready, they are sent to Apache. Apache begins sending these 4096 bytes to the client.

Here I do not understand: what happens when there is some kind of nasty callout for the tracker, javascript or image that was sent to the browser. The browser is suspended and does not talk with Apache for a while, holding it. Apache does not release a MySQL thread that appears as "sleeping". Is this right or am I completely out of here?

+4
source share
2 answers

You are completely out of base :)

what happens when there is some kind of nasty callout tracker, javascript or image sent to the browser

This will not affect anything on the server side.

Every request executed through PHP will

  • Compile the necessary PHP files to select the code (if caching is not one)
  • Run optional PHP code
  • Return string results of PHP code to browser

The buffering you are talking about happens between steps 2 and 3. So, let's take a look at your scenario.

  • PHP URL request made
  • Opt code compiles
  • PHP execution starts and starts returning html strings
  • Created a line with a slow boot img tag
    • PHP continues to produce output in apache
    • A separate HTTP request is created for the image (or javascript code, or something else, etc.)

This is a separate request, which is impotent here. All PHP and Apache return HTML to the browser. This HTML may call the img or javasript tag, which will call back to the same web server, but these requests will be processed separately from the request that creates the HTML for the existing page.

+4
source

The browser does not get "freezes from loading HTML data from the server." It continues to load the entire page, even if it waits for the JavaScript file to go down before it actually displays it.

Of course, if the connection between the browser and the server is interrupted for some reason, you can make Apache depend on waiting for the ACK until the connection time is over, but this is not the usual case.

+2
source

All Articles