What are the potential benefits and drawbacks of using the flush function in PHP?

Using the flush function in PHP can be beneficial for real-time output of data to the browser, such as progress updates during a long-running process. However, it can also lead to increased server load and potential performance issues if overused or misused.

ob_start();

// Long-running process
for ($i = 0; $i < 10; $i++) {
    echo "Progress: $i/10<br>";
    flush();
    sleep(1);
}

ob_end_flush();