How Much RAM/MEMORY for PHP-FPM

Newbie here, but can learn.

I’m running HestiaCP 1.2.3 hosting low traffic production websites.

  • VPS is on DigitalOcean with 4GB RAM
  • HestiaCP setup is - multiphp enabled, with apache, php-fpm, nginx for proxy

Question: How much RAM to allocate for php-fpm in hestiacp admin settings? How to calculate? Is this for the whole system, or for each domain, or user?

It can be tricky to calculate. From what I understand, each PHP-FPM web domain spawns a PHP-FPM process when visited, which consumes X KB or memory and can handle Y number of requests. First you need to find out how much memory X is, by using something like the ps aux | grep php-fpm command.

Now, if you have Z number of PHP-FPM web domains hosted on the server, the memory that you will need for PHP-FPM will be X * Z, provided that the total number of concurrent requests for each site is smaller than Y. You can find out about Y inside the config for /etc/php/7.*/fpm/pool.d/FQDN.conf and look for pm.max_requests =