Search code examples
phpio

Return the page to the client, and do a final IO blocking operation


When generating a page with PHP:

<?php
echo "Hello world";
// generate the HTML output
// HTML finished here
send_output_to_client();       // <-- how to do this?

perform_blocking_IO_operation();      // this can last 100 ms or more, this will not output anything anymore, 
                                      // only internal logging IO operations
?>

how to ask PHP to send the output to the client and don't wait for perform_blocking_IO_operation() to finish?

Since perform_blocking_IO_operation() can last 100 ms or more, I'd like to avoid this unnecessary waiting time for the client.


Solution

  • Use flushing as mentioned above or RabbitMQ.