Apache and PHP possibilities, now we have FPM

Now with Sympl 12 we have the option of PHP-FPM, I am thinking of the possibilities for performance improvement and reduction of memory usage. My knowledge of Apache configuration is fairly basic.
I now have one or two sites using PHP-FPM, and many using the default mod-php. Apache is still using mpm-prefork as it seems to be required for mod-php.
Questions for Apache experts:

  • If I convert most of them to PHP-FPM, does that mean I could reduce the number of apache processes, as fewer will be needed? (as I understand it, this would only apply to PHP files; other files like CSS, text and graphics would still be handled by an apache process)
  • If I convert all sites to PHP-FPM, would I be able to disable MOD-PHP altogether, making each apache process smaller?
  • If I could do that, would I then be able to switch to mpm_worker or mpm_event, or would that break Sympl?
  • What improvements in performance or memory use could I expect from any of the above steps?

I’ve read lots of general online advice about how to run PHP with Apache and the different MPM options; my main concern here is compatibillity with Sympl.

Interesting is there an official view on this? I have 4 vms that might benefit, so might just ask the good folk at Mythic directly!

might just ask the good folk at Mythic directly!

I don’t think Mythic would be concerned about this. The issue is only related to the Sympl package.

I am running all my web sites on PHP8.3-FPM now (apart from one that needs an earlier version), but still have mod-php installed because I couldn’t work out how to configure PHPMyadmin and Roundcube to use FPM.

Swapping everything to use FPM specifically isn’t on the roadmap for Sympl 13 (there’s a fair bit of work to do involving reimplementing other features), but if you were to disable mod-php, and set up separate Roundcube and phpMySQL instances that would be one way to do it.

Note however that the footprint for mod_php isn’t that huge, and you’re running PHP instances for the FPM sites, which have a fair bit more of a memory footprint, so you wouldn’t be saving much.

It’s entirely unknown at the moment if it would break Sympl - it would certainly break it being supportable though!

There are some plans to add more functionality and options to the sympl-web package, and potentially run it under different MPMs (specifically to improve security and isolation), but it’s entirely untested at the moment.

It’s unlikely it would be anything huge - it’s not so much the PHP processes within Apache sitting there which use the ram, it’s the code being run in them which tends to use the memory, and you still need to be able to spawn Apache processes to handle the HTTP/HTTPS connections.

You may want to look into what’s using the majority of your RAM at the moment - htop can be handy for this, but on the ‘nice to have’ list, I plan to add some extra ram usage monitoring in Sympl 13.

Actually, since starting this thread (a year ago now) I’ve done a fair amount of experimenting with numbers of server processes in both Apache and PHP-FPM, and using htop to get some idea of memory usage, and I think I’ve got everything fairly balanced now, in terms of getting performance without running out of memory.

Your ram usage monitoring tool might be useful though. I’m never sure if I’m interpreting htop’s memory figures correctly, though it’s very handy for watching apache and PHP-FPM child processes coming and going.