Results 1 to 12 of 12

Thread: Has anyone noticed Apache + PHP FPM is amazingly slow?

  1. #1
    Join Date
    Dec 2005
    Posts
    103

    Has anyone noticed Apache + PHP FPM is amazingly slow?

    With a standard prefork install apache is decently fast on my machine, pumping out around 5MB/s.

    But when I recompile with PHP FPM its quite slow (1.5-2 MB/s). Ive tried tuning the server event MPM in all different ways with no benefit.

    I wouldnt expect such a striking difference between the two. Has anyone noticed this? Any suggestions on how to diagnose the issue?

  2. #2
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    11,023
    Hello,

    server-status? netstat?
    With regards, Alex.

    Professional Server Management for web hosting companies and individuals
    Hourly Support, Disaster Recovery, Server Hardening, Monthly Subscription
    Directadmin installation and optimization

    Click here if you need a Linux Admin

  3. #3
    Join Date
    Dec 2005
    Posts
    103
    Quote Originally Posted by zEitEr View Post
    Hello,

    server-status? netstat?
    Not sure which data you wanted to see, but here is the server-status data from the CLI PREFORK

    Code:
    Current Time: Wednesday, 24-Oct-2012 19:36:24 CDT
    Restart Time: Wednesday, 24-Oct-2012 01:27:30 CDT
    Parent Server Config. Generation: 1
    Parent Server MPM Generation: 0
    Server uptime: 18 hours 8 minutes 54 seconds
    Total accesses: 14304233 - Total Traffic: 342.3 GB
    CPU Usage: u12584.6 s721.93 cu.66 cs3.43 - 20.4% CPU load
    219 requests/sec - 5.4 MB/second - 25.1 kB/request
    507 requests currently being processed, 355 idle workers
    ______KKKKR_K______W_KKC___CKK_K_K_W__CC_KKK_KK._K_K_KK._KKKK_K_
    K_____KK_KKKK_K_KK__K___KK_K___K_____CKKK_WK_K_____KCKK__K___K_K
    K_CK_K_K_____K__KKKK_K__K___K_KK_K_K_KKKCK____________KK_CK__KKK
    __C_KKKKKKK___CK___C_KKK_K__C__K_CK____KKK__K__K__K_K__KK_CK_K__
    _KKKKK_K_W__KK______K___K__W___C_K__K____KKKKKKKK.KKKKKKKCK_K___
    _C_KK_K_WK__K_KK__K__RK_KK___K____K_KK_K_K___RKC_KKKK___KKKC_K_W
    _C_KK_KK__W____KC__KKK__KKK___K___KKK_KK_K_KKW__K_KR_KK_KK__KKK_
    R__KKK__KKKKKK__K_KKKKK_K__K_K___KKW_________KK_K___KKK___KK.K_C
    KKKKKKW_____K__K_KKC_KCKK_K_KK_K__KK__K___K__KK_KK__________KK__
    __K___KK_K__K_C_KK_K___KK__KK__K__KCK_K__KK_________K_K_KK__.K__
    K_CKK.CCRW__KKKKKKKKKKKC__W____K___KWK_KK_KKC______.K_K_KK_KKKC_
    __KKK_W_KCKKK_K_K____CCCK__KC_KKKK_K____K_CK_K____K__K____KKK_KK
    KK___K_K_K__KW__KCKKKK____WKWK__K_KKRKK__C_K_KK_KK_K__KKCC_K__C_
    KK_K___K_KK______K_____CKK_K_______KK_CKCK__KKKKK____K__K..K____
    __KKWK_KW__KKK__K_KKK___K_KK_KKK__KK___KK___KK_KK___KK____KKWKKC
    KK_KKKK_................................
    Here it is from the PHP FPM with event MPM

    Code:
    Server Version: Apache/2.4.3 (Unix) OpenSSL/1.0.0-fips mod_fastcgi/mod_fastcgi-SNAP-0910052141
    Server Built: Oct 24 2012 19:40:44
    Current Time: Wednesday, 24-Oct-2012 19:51:21 CDT
    Restart Time: Wednesday, 24-Oct-2012 19:48:03 CDT
    Parent Server Config. Generation: 1
    Parent Server MPM Generation: 0
    Server uptime: 3 minutes 18 seconds
    Total accesses: 18720 - Total Traffic: 307.1 MB
    CPU Usage: u16.57 s4.74 cu0 cs0 - 10.8% CPU load
    94.5 requests/sec - 1.6 MB/second - 16.8 kB/request
    15 requests currently being processed, 49 idle workers
    PID	Connections	Threads	Async connections
    total	accepting	busy	idle	writing	keep-alive	closing
    11701	114	no	10	22	0	66	38
    11702	134	no	5	27	0	81	48
    Sum	248	 	15	49	0	147	86
    __R_R__W___RRW________RR__R___W_W_______W_____W_____________R_R_
    Notice the drastic difference in requests/s etc
    Last edited by darkus; 10-24-2012 at 06:13 PM.

  4. #4
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    11,023
    Yes, I see. More details can be get with enabled extended status.

    They still say mod_php is the quickest...
    With regards, Alex.

    Professional Server Management for web hosting companies and individuals
    Hourly Support, Disaster Recovery, Server Hardening, Monthly Subscription
    Directadmin installation and optimization

    Click here if you need a Linux Admin

  5. #5
    Join Date
    May 2008
    Location
    The Netherlands
    Posts
    1,158
    I was curious and decided to test it as well, I just grabbed an iso file of 200 MB and first read it into php and output it to the client and then just download it through apache directly

    Through php-fpm:
    Code:
    Length: 209715200 (200M) [application/octet-stream]
    Saving to: `t.php'
    
    100%[===================================================================================================================================================================================================>] 209,715,200 6.92M/s   in 30s
    
    2012-10-26 19:01:09 (6.61 MB/s) - `t.php' saved [209715200/209715200]
    Through plain apache:

    Code:
    Saving to: `CentOS-6.3-x86_64-netinstall.iso'
    
    100%[===================================================================================================================================================================================================>] 209,715,200 6.90M/s   in 30s
    
    2012-10-26 19:02:37 (6.60 MB/s) - `CentOS-6.3-x86_64-netinstall.iso' saved [209715200/209715200]
    As you can see no difference, php isn't limiting the speed at all. Or are you doing something else? If you want I can paste the little php script I used.

  6. #6
    Join Date
    Dec 2005
    Posts
    103
    Quote Originally Posted by zEitEr View Post
    Yes, I see. More details can be get with enabled extended status.

    They still say mod_php is the quickest...
    I enabled extended status, it just lists all the actual connections, do you want to see those too? Its just a massive list of urls etc.. let me know if this is helpful?


    Quote Originally Posted by Arieh View Post
    I was curious and decided to test it as well, I just grabbed an iso file of 200 MB and first read it into php and output it to the client and then just download it through apache directly

    Through php-fpm:
    Code:
    Length: 209715200 (200M) [application/octet-stream]
    Saving to: `t.php'
    
    100%[===================================================================================================================================================================================================>] 209,715,200 6.92M/s   in 30s
    
    2012-10-26 19:01:09 (6.61 MB/s) - `t.php' saved [209715200/209715200]
    Through plain apache:

    Code:
    Saving to: `CentOS-6.3-x86_64-netinstall.iso'
    
    100%[===================================================================================================================================================================================================>] 209,715,200 6.90M/s   in 30s
    
    2012-10-26 19:02:37 (6.60 MB/s) - `CentOS-6.3-x86_64-netinstall.iso' saved [209715200/209715200]
    As you can see no difference, php isn't limiting the speed at all. Or are you doing something else? If you want I can paste the little php script I used.
    Agreed! I would expect there to be no difference just as your test confirms.

    The way im switching between the two is literally changing to cgi/cli in the options.conf file for CB2, then I ruin ./build apache ./build php n. That is all. The numbers show a big difference, and the user experience is even more magnified. Pages can ake up to 30 seconds just to start loading with the php-fpm module. It just feels like it is choking itself up, but no amount of server tuning changes much of anything. On the plus side server loads become just about half. But again, that makes me think the software is somehow choking itself

  7. #7
    Join Date
    May 2008
    Location
    The Netherlands
    Posts
    1,158
    Well it now seems to be more just a local issue rather than a structural one. My experience is that if a website has been inactive for a very long time (like I have on my test cb 2.0 environment it takes a little time before it gets fired up. Especially if it's a heavy site like magento, it may take a few hits of 10 seconds on my machine. Then when you start browsing the site a big it gets faster and faster until it's decent.
    Smaller/optimized sites are way faster up to speed, with the first hit -- but you may notice it slightly. I guess thats normal, because when they're active they consume memory and then release it when inactive. It's something all CGI implementations face really.

    But by the sounds of it this does not seems to be the issue? I have no clue what it may be then, maybe someone else knows.

  8. #8
    Join Date
    Dec 2005
    Posts
    103
    Quote Originally Posted by Arieh View Post
    Well it now seems to be more just a local issue rather than a structural one. My experience is that if a website has been inactive for a very long time (like I have on my test cb 2.0 environment it takes a little time before it gets fired up. Especially if it's a heavy site like magento, it may take a few hits of 10 seconds on my machine. Then when you start browsing the site a big it gets faster and faster until it's decent.
    Smaller/optimized sites are way faster up to speed, with the first hit -- but you may notice it slightly. I guess thats normal, because when they're active they consume memory and then release it when inactive. It's something all CGI implementations face really.

    But by the sounds of it this does not seems to be the issue? I have no clue what it may be then, maybe someone else knows.
    Yea I dont think that is the issue, and did test for exactly what you are saying but letting the server run for a good hour under the php-fpm with no real change

  9. #9
    Join Date
    Dec 2005
    Posts
    103
    SOLUTION

    I've been tuning my PHP-FPM by editing this file which seemingly has all the FPM variables:
    /usr/local/php54/etc/php-fpm.conf

    HOWEVER. There is another file which gets loaded after the first file, which contains a partial set of the FPM variables, including the key children max variable.
    /usr/local/directadmin/data/users/admin/php/php-fpm54.conf

    The second set of partial variables overrides the first .conf file settings, and so some of the changes Ive been making have not taken any effect. Im not sure why the settings are arranged this way, but basicly if you want to tune your PHP-FPM you have to change the variables between those two .conf files, remembering the variables in the second file supercede the first one. Now that i'm tuning both files simultaneously, I now notice significant increases in speed
    Last edited by darkus; 10-28-2012 at 03:59 PM.

  10. #10
    Join Date
    Oct 2003
    Location
    Switzerland
    Posts
    2,097
    php-fpm has per user settings, so DA will probably copy some defaults to each user config, but it's those files you want to edit, including if you want to play with PHP flags.
    Olivier
    interfaCentre - We design custom hosting solutions

    Custom apps, scripts and configurations for easy and secure access to all hosting services
    Full Personal Information Management suite with mobile synchronisation
    PHP, Ruby, Node.js and Python hosting with 1-click app install

  11. #11
    Join Date
    Sep 2014
    Posts
    51

    never succeeded in getting any benefits from php-fpm

    Hi,
    I had setup a test lab with nginx and php fpm, and i have noticed that my websites were all slower whatever the load and content.
    Surprinsgly i have installed apache 2.4 with php-fpm and my websites were as slow as nginx with php-fpm.

    So i have decided to look into php-fpm.conf to see whether i could change anything. I have switch the pm to "dynamic" rather than "ondemand". I have tried to tweak the configuration. i received a 503 error on my pages and said: "ok let's go back to mod_php (with custombuild in options.conf) and say goodbye to the hype").

    I have done some googling about php-fpm. I have found their website project and i have seen there were no news since PHP 5.3 and 2011.

    Then, i have found that other webmasters witnessed php-fpm was slow.


    So, i prefer to sacrifice a bit of RAM rather than getting a slow web server for my visitors.

    EDIT:
    I did a mistake, i only changed the php-fpm56.conf from the master file.
    I have understood that one php-fpm56.conf exists per user. I changed the local php-fpm56.conf to pm=dynamic and it works great. use locate php-fpm56.conf to see what i mean.
    Last edited by jojolafrite; 09-14-2015 at 10:24 AM.

  12. #12
    Join Date
    Oct 2003
    Location
    Switzerland
    Posts
    2,097
    Quote Originally Posted by jojolafrite View Post
    Hi,
    I had setup a test lab with nginx and php fpm, and i have noticed that my websites were all slower whatever the load and content.
    Surprinsgly i have installed apache 2.4 with php-fpm and my websites were as slow as nginx with php-fpm.

    So i have decided to look into php-fpm.conf to see whether i could change anything. I have switch the pm to "dynamic" rather than "ondemand". I have tried to tweak the configuration. i received a 503 error on my pages and said: "ok let's go back to mod_php (with custombuild in options.conf) and say goodbye to the hype").

    I have done some googling about php-fpm. I have found their website project and i have seen there were no news since PHP 5.3 and 2011.

    Then, i have found that other webmasters witnessed php-fpm was slow.


    So, i prefer to sacrifice a bit of RAM rather than getting a slow web server for my visitors.
    You need to define slow...
    Is it the initial handshake?
    Did you measure it with your browser's dev tools to see what was loading slowly?
    Did you enable the /status page in php-fpm to see what's going on?

    Standard status page
    Code:
    pool:                 www
    process manager:      dynamic
    start time:           17/May/2013:13:54:02 +0530
    start since:          886617
    accepted conn:        1619617
    listen queue:         0
    max listen queue:     0
    listen queue len:     0
    idle processes:       28
    active processes:     2
    total processes:      30
    max active processes: 31
    max children reached: 0
    slow requests:        0
    Extended info about a process
    Code:
    pid:                  1419692
    state:                Idle
    start time:           27/May/2013:20:06:12 +0530
    start since:          287
    requests:             32
    request duration:     188927
    request method:       GET
    request URI:          /feed.php?uid=12997446135571490564
    content length:       0
    user:                 -
    script:               /var/www/example.com/htdocs/feed.php
    last request cpu:     5.29
    last request memory:  524288
    Some tips on how to enable it
    https://rtcamp.com/tutorials/php/fpm-status-page/
    Olivier
    interfaCentre - We design custom hosting solutions

    Custom apps, scripts and configurations for easy and secure access to all hosting services
    Full Personal Information Management suite with mobile synchronisation
    PHP, Ruby, Node.js and Python hosting with 1-click app install

Similar Threads

  1. Replies: 0
    Last Post: 02-14-2009, 08:14 PM
  2. help with apache (server is slow)
    By daniel in forum Apache (WWW)
    Replies: 17
    Last Post: 12-12-2005, 09:23 AM
  3. some apache erros i noticed
    By servertweak in forum General Technical Discussion & Troubleshooting
    Replies: 1
    Last Post: 06-20-2005, 07:04 PM
  4. Apache slow?
    By Smooth_J in forum Apache (WWW)
    Replies: 1
    Last Post: 02-22-2005, 08:04 AM
  5. Has anyone else noticed this with Webalizer?
    By digilexic in forum General Technical Discussion & Troubleshooting
    Replies: 7
    Last Post: 06-25-2004, 07:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •