Score:0

PHP-fpm consuming most memory

ga flag

My Memory and swap memory is being used mostly by php-fpm which results in slow response from server. below is the output of top command. Kindly suggest

enter image description here

Also my php-fpm conf file settings are as follows:

pm = ondemand
pm.max_children = 250
pm.process_idle_timeout = 3600s;
pm.max_requests = 500
Nikita Kipriyanov avatar
za flag
In principle, this is precisely why you have memory in the server: to make it available for applications. It is normal that applications use it, it is there just for that. Is this much usage normal or not is completely different question, though, and it depends on the application that is being executed inside *entirely*. I am afraid we can't help with that. Anyway, it is impossible to help without knowing exactly what application(s) is(are) there and what is their configuration, but still that might be off topic on ServerFault.
Nikita Kipriyanov avatar
za flag
This process of determining the weak point (the cause of the slowdown) is called *application profiling* and it is usually being done by the application developers who have access to the source code, or system integrators. The memory usage alone *does not necessarily* cause the slow response from the server. Your CPU is sitting doing nothing and there is no waiting for the I/O, which means there is no memory pressure. The memory usage is the interesting symptom in this case, but unlikely the direct cause.
Score:0
za flag

Memory consumption by a pool of php workers mainly depend on two factors:

  • the limit of pm.max_children
  • the php.ini memory limit of memory_limit (which seem to be around of 1 Gb).

Product of these two numbers will give you the memory consumption when the pool is busy.

So, basically, you have three options:

  • decrease the number of php workers
  • decrease the memory_limit
  • increase the number of servers running php pool of workers (while keeping the total memory consumption limit of the php pool within host physical memory boundaries).
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.