Skip to content

Ensure fast flush of HTTP headers and HTML head#2045

Merged
Alkarex merged 4 commits intoFreshRSS:devfrom
Alkarex:fast-flush
Oct 14, 2018
Merged

Ensure fast flush of HTTP headers and HTML head#2045
Alkarex merged 4 commits intoFreshRSS:devfrom
Alkarex:fast-flush

Conversation

@Alkarex
Copy link
Copy Markdown
Member

@Alkarex Alkarex commented Oct 13, 2018

The fast flush optimisation done in #1133 does not seem to work anymore (need to check if it is related to a PHP version).
Work-around when PHP flush() is not working.
Can be tested by adding a sleep(5); after:


Follow-up of the performance checks of #2040

The fast flush optimisation done in
FreshRSS#1133 does not seem to work
anymore (need to check if it is related to a PHP version).
Work-around when PHP flush() is not working
Can be tested by adding a `sleep(5);` after:

https://github.com/FreshRSS/FreshRSS/blob/ee902ee7c4370421802768c3105ba269a4f97b16/app/layout/layout.phtml#L27
Follow-up of the performance checks of
FreshRSS#2040
@Alkarex Alkarex added this to the 1.12.0 milestone Oct 13, 2018
@Alkarex
Copy link
Copy Markdown
Member Author

Alkarex commented Oct 13, 2018

This is quite strange. flush() used to work fine - as far as I can recall - but I cannot make it to work now. Tested on:

  • PHP 7.2.10 on Ubuntu 18.04 with Apache 2.4.29
  • PHP 7.0.32 on Ubuntu 16.04 with Apache 2.4.18
  • PHP 7.2.8 on Alpine 3.8 with Apache 2.4.34
  • PHP 5.6.36 on Alpine 3.4 with Apache 2.4.33

Turning on/off Apache DEFLATE makes a difference when PHP runs as CGI, not when running as module.

Documentation:

In my tests, it looks like flush() only works when the value of output_buffering is smaller than what flush() releases.

To test in FreshRSS, add a delay after flush(), e.g. add sleep(10); after the line

To test outside FreshRSS:

<html>
<body>
<pre>
Before...
<?php flush(); sleep(5); ?>
Between...
<?php flush(); sleep(5); ?>
End.
</pre>
</body>
</html>
curl -v -N 'http://example.net/flush.php'
# And
curl -v -N --compressed 'http://example.net/flush.php'

You are supposed to see an output with HTTP headers and the first part of the HTML, then a pause, then some more. If you only see one long pause and get all the output at once, it is wrong.

Additional help / testing welcome.

@Alkarex Alkarex added the Work in progress 🚧 Wait before merging label Oct 14, 2018
Flush a bit later, to be compatible with the default value of 4096 for
PHP output_buffering, and thus avoid the need of tuning the value.
@Alkarex
Copy link
Copy Markdown
Member Author

Alkarex commented Oct 14, 2018

The fast flush speed optimisation works fine together with compression when PHP runs as Apache module (like we do in the Docker image).
However, I have not found a way to have at the same time compression and fast flush when PHP runs as CGI / FastCGI / FPM. Tips welcome.

Alkarex added a commit that referenced this pull request Oct 14, 2018
@Alkarex Alkarex merged commit 5b030dc into FreshRSS:dev Oct 14, 2018
@Alkarex Alkarex deleted the fast-flush branch October 14, 2018 12:37
@Alkarex Alkarex mentioned this pull request Oct 14, 2018
mdemoss pushed a commit to mdemoss/FreshRSS that referenced this pull request Mar 25, 2021
* Ensure fast flush of HTTP headers and HTML head

The fast flush optimisation done in
FreshRSS#1133 does not seem to work
anymore (need to check if it is related to a PHP version).
Work-around when PHP flush() is not working
Can be tested by adding a `sleep(5);` after:

https://github.com/FreshRSS/FreshRSS/blob/ee902ee7c4370421802768c3105ba269a4f97b16/app/layout/layout.phtml#L27
Follow-up of the performance checks of
FreshRSS#2040

* output_buffering in .user.ini for PHP CGI / FPM

* Reuse .user.ini for Docker PHP config

* Longer flush

Flush a bit later, to be compatible with the default value of 4096 for
PHP output_buffering, and thus avoid the need of tuning the value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant