Nginx + php-fpm

Discussion in 'Server Operation' started by theCCstone, Jun 9, 2013.

  1. theCCstone

    theCCstone New Member

    Hello, I have a problem in the processes of php-fpm. I migrated from apache to nginx, however with nginx and php-fpm happens the following problem: php-fpm, even after closing the client connection, the process is still active in the system. Causing me to get the process of restarting php-fpm hourly. If anyone can help me, I'm grateful
     
  2. saosangmo

    saosangmo New Member

    hi theCCstone,
    I'm newbie here and get the same problem. Did you find the solutions?
    thanks
     
  3. levina85

    levina85 New Member

    I am also having the same problem in Nginx. Were you able to find the solution to the issue?
     
  4. harkman

    harkman New Member HowtoForge Supporter

    I'm not a expert, but as far as I understand the system of nginx and php-fpm both maintain a pool of worker threads.

    If you have multiple websites that use their own priviliges both services will start at minimum 1 process for each site, to serve incomming requests.

    Starting new processes is very expensive in regards to processing time, therefore at least one worker process for each site should stay in the memory of the server, waiting for new requests.

    If you kill those processes, you will only raise the response time of your websites.

    Regards, J├╝rgen
     
    Last edited: Jul 2, 2013
  5. theCCstone

    theCCstone New Member

    Their placement is correct. My problem is that in addition to the standard thread. When more than one person accesses the website, it does not return to the default one processor, it is with the other assets in the memory accesses, slowly consuming all system memory. Thus it becomes impossible to use. If anyone knows anything, please help :)
     
  6. pititis

    pititis Member

    The solution is use ondemand mode in each pool configuration.

    Change:

    pm = dynamic (or pm = static)

    for

    pm = ondemand

    and restart fpm.

    ondemand mode needs (PHP Version >= 5.3.9)

    Also see the pm.max_children and pm.process_idle_timeout directives if you choose ondemand mode

    Code:
    ;  ondemand - no children are created at startup. Children will be forked when
    ;             new requests will connect. The following parameter are used:
    ;             pm.max_children           - the maximum number of children that
    ;                                         can be alive at the same time.
    ;             pm.process_idle_timeout   - The number of seconds after which
    ;                                         an idle process will be killed.
    
    
    Cheers!
     
  7. theCCstone

    theCCstone New Member

    Thank you. Worked perfectly now = D
     

Share This Page