I'm using mod_proxy_fcgi with apache 2.4 on a debian Jessie with my C++ application which does ServerSentEvents with libfcgipp.
My problem is, that apache still buffers my response data. I confirmed that it isn't buffered by the libfcgipp library by using wireshark: After starting the fcgi application via spawn-fcgi
, the data gets send to the apache web server as soon as possible. But in my browser (which I use for testing, later there will be a C++ client) it only shows up after I "killed"/closed the sending request in the server application.
So I assume I need to disable buffering for either apache or mod_proxy_fcgi (or both). But I cannot find the appropriate documentation on how to do this.
A few notes, since I just spent the past few hours experimenting to find the answer to this question:
mod_proxy
/mod_proxy_fcgi
, however, you can still have responses streamed in chunks.mod_fastcgi
or mod_fcgi
module, but those mods aren't as popular/widely used with Apache 2.4.mod_deflate
enabled and don't set SetEnv no-gzip 1
for the virtualhost/directory/etc. that's streaming data, then gzip will not allow the buffer to flush until the request is complete.I was testing things out to see how to best use Drupal 8's new BigPipe functionality for streaming requests to the client, and I posted some more notes in this GitHub issue.
As the result of a subsequent discussion on the httpd-dev mailing list, support for flushpackets
and flushwait
was added to mod_proxy_fcgi
in r1802040 and backported for Apache 2.4.31 in r1825765. If you are using Apache 2.4.31 or later, you can disable buffering using <Proxy flushpackets=on>
as described in the BigPipe documentation:
<FilesMatch "\.php$">
# Note: The only part that varies is /path/to/app.sock
SetHandler "proxy:unix:/path/to/app.sock|fcgi://localhost/"
</FilesMatch>
# Define a matching worker.
# The part that is matched to the SetHandler is the part that
# follows the pipe. If you need to distinguish, "localhost; can
# be anything unique.
<Proxy "fcgi://localhost/" enablereuse=on flushpackets=on max=10>
</Proxy>
Note: flushpackets
and flushwait
are currently only included in the Apache mod_proxy_fcgi
documentation for trunk
because r1808129 has not been backported to the 2.4.x branch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With