Re: Apache hangs after having 6 x SSE streams active
"Edward J. Sabol" <[email protected]> Thu, 23 Oct 2025 13:25:22 -0400
| Newsgroups | gmane.comp.apache.mod-perl |
|---|---|
| Message-ID | <[email protected]> |
Mod_perl won't work with mpm_event and threads unless you compile Perl with s= pecific options and avoid doing certain things which can cause segmentation f= aults in Perl. You can't just use an "off-the-shelf" version of Perl. Search= the mod_perl mailing list archives for posts by Joe Schaefer going back ove= r the past ~3 years for clues on how to do that and check out his sealed.pm m= odule. I haven't done it or used it personally. It sounds non-trivial to set= up properly. If you try going down this route, please report back with your= findings. According to conventional wisdom, mpm_prefork works better (or at least easi= er) for mod_perl and is often recommended for mod_perl. Most mod_perl develo= pers avoid using threads entirely because the combination of mod_perl and th= reads is so problematic. Mpm_prefork is less efficient than mpm_event by mos= t accounts, of course. You would certainly need to configure Apache to have w= ay more than 4 servers with mpm_prefork. Good luck, Ed > On Oct 23, 2025, at 11:42=E2=80=AFAM, Steven Haigh via modperl <modperl@pe= rl.apache.org> wrote: > I'm writing a web UI in perl + mod_perl that sends an SSE stream to the br= owser full of JSON formatted updates etc. The browser then renders that all v= ia Javascript to the user. >=20 > I've noticed that if I reload the page multiple times, or just navigate aw= ay, when there's ~6 existing SSE streams, apache will stop accepting new con= nections completely. >=20 > I've hunted around via the normal search engines, turned up very little - a= nd out of desperation, asked ChatGPT's Codex... >=20 > It suggested the following apache config: >=20 > LoadModule mpm_event_module modules/mod_mpm_event.so > # Tune event MPM so we have headroom for long-lived SSE connections > <IfModule mpm_event_module> > ServerLimit 4 > StartServers 2 > MinSpareThreads 50 > MaxSpareThreads 150 > ThreadsPerChild 64 > MaxRequestWorkers 256 > MaxConnectionsPerChild 0 > </IfModule> >=20 > ## Load mod_perl > LoadModule perl_module /usr/lib/apache2/modules/mod_perl.so > PerlModule Apache2::Reload > PerlInitHandler Apache2::Reload > PerlOptions +Parent > PerlSwitches -Mlib=3D/usr/local/apache2/htdocs-includes > PerlInterpStart 20 > PerlInterpMinSpare 10 > PerlInterpMaxSpare 20 > PerlInterpMax 80 >=20 > Even with this however, when I hit 6 x concurrent SSE streams being served= , Apache grinds to a halt and doesn't even load the /server-status/ page for= troubleshooting. >=20 > Once some of the 'dead' SSE streams fail and those connections terminated,= apache starts behaving again. >=20 > Has anyone come across this before and maybe knows a bit of additional kno= wledge as to why this is, and what I can do about it?