2

I'm running PHP-FPM on my Debian servers. My question is about the memory usage. I can only set the memory_limit inside PHP, and that shouldn't be too low for some requests. I also can only set the number of processes in PHP-FPM and that, also, should not be too low since I'm running a lot of php requests.

In most cases, processes will only use around 2-20mb. The process limit is 512, so that's roughly 5-10GB of RAM. But since some php scripts can use a lot more memory, the maximum allowed memory is around 1TB (512 processes * 2048mb). And if something goes wrong, the Debian OOM Killer will just randomly kill processes.

Is there any way to limit the total memory usage for php-fpm? Like a hard limit where php-fpm won't spawn more processes because it's out of total RAM.

Jochen Ullrich
  • 123
  • 1
  • 3

1 Answers1

0

Few days ago I had similar problem, when couple of php5-fpm masters spawned too much processes. OOM Killer helped a lot by killing nginx.

As solution I found cgroup mechanism with memory subsystem. It allows to put all FPM processes in 1 group which is limited to e.g. 60% of system RAM.

Great documentation: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Resource_Management_Guide/ch-Using_Control_Groups.html

Tomasz Olszewski
  • 868
  • 9
  • 20