Need some tips for tuning the web server

Discussion in 'Install/Configuration' started by canglan, Aug 29, 2009.

  1. canglan

    canglan New Member

    Hi guys,

    We are currently using LSWS to power a number of Wordpress installations on a 2GB VPS slice. The VPS slice is dedicated for serving LSWS requests (so MySQL is served remotely), LSWS is the latest (4.0.10 Enterprise), PHP is 5.2.10 with APC and Memcache enabled. The Wordpress installations all have W3 Total Cache enabled too.

    However, we are still seeing relatively high server load. From 'top', it appears that lsphp5 processes are using quite a bit of CPU power.

    Below are some of the configuration parameters:

    [​IMG]

    [​IMG]

    [​IMG]

    I've tried a few different tweaks and nothing I did seem to bring the CPU usage down. :|

    It is also unlikely the Wordpress installations are causing the issue, because these sites were hosted elsewhere using Apache + mod_php before, and the CPU usage was fine.

    Some interesting stuff from the server log:

    [​IMG]

    And the requests/second graph (during this time, server load averages at around 0.8 to 1.3):

    [​IMG]


    Any suggestions?
    Last edited: Aug 29, 2009
  2. anewday

    anewday Moderator

  3. robfrew

    robfrew New Member

    High cpu usage stats is normal but it does not affect performance or any other areas of the server. We average between 1.8 to 3.5 during busy times and our server is blazing fast with mysql, php and many other service running. Nothing to worry about with your cpu usage.
  4. canglan

    canglan New Member

    I see, thanks guys.

    The reason for my post is that, the posted server load was taken during off peak time, and the current server only hosts a small portion of our sites. We are planning to migrate our larger sites to the same server in the upcoming weeks, and I was a bit worried that the server might not coupe very well once the larger sites are up and running. :|

    I guess I'll slowly migrate those sites over and see how it goes.
  5. mistwang

    mistwang LiteSpeed Staff

    Max idle time and connection keepalive timeout should not be set. Initial request timeout should be around 60.

    What you see probably is normal as LSWS uses minimum number of persistent PHP processes to serve all requests, CPU utilization may looks like for indivudal process, but the overall system level CPU utilization is lower.
  6. mistwang

    mistwang LiteSpeed Staff

    Another note on W3 Total Cache, looks like everything is still served by PHP, just cached by memcache or something. it is slower than WP super cache, if you do not need to keep everything dynamic or any specific need for features in W3 Total Cache, WP super cache is a better choice for busy blog site. Serving a static page is 100X faster than serving a PHP page.
  7. canglan

    canglan New Member

    Thank you mistwang! I've unset max idle time and connection keepalive timeout and set the initial request timeout to 60 per your instruction. On a busy site though, wouldn't that cause unneccesarry overheads? i.e. too many idle/keep alive connections?

    It's interesting that you mentioned the two Wordpress caching plugins, I am always under the impression that because memcache is caching on the memory level, it will be faster than serving static pages. I briefly benchmarked WP Super Cache and W3 Total Cache before rolling the latter one to all our Wordpress installations, and the result was in favour of W3 Total Cache. I guess I should do a more comprehensive benchmark later on, just to make sure we are on the right track. :)
  8. canglan

    canglan New Member

    We have just experienced an unusual high load. There were lots of lsphp5 processes, I'm not sure how to tackle this issue, here's a snapshot of the processes:

    [​IMG]
  9. mistwang

    mistwang LiteSpeed Staff

  10. canglan

    canglan New Member

    Thanks mistwang. I had looked into the possibility of a small scale DoS attack. But at the time of the high load (which sustained for about 10-15 minutes), requests per second was only about 50-60, which the server should have handled it without causing such a high load. There was no cron jobs running at the time, no errors from either the server log or PHP log.

    I will investigate more. :|
  11. canglan

    canglan New Member

    Hi mistwang,

    I think I need some more help.

    Our server has just had a huge load spike, lsphp5 was taking up all the CPU, and made the server unresponsive, couldn't even ping or SSH into the server.

    [​IMG]

    The server log just before the huge spike (domains are masked):

    2009-09-07 03:01:52.427 [INFO] [70.32.68.11:54866-0#APVH_xxx.xxx.xxx] connection to [/tmp/lshttpd/lsphp5.sock.582] on request #25, confirmed, 0, associated process: 5282, running: 1, error: Connection reset by peer!
    2009-09-07 03:02:42.006 [INFO] [64.127.102.82:17873-0#APVH_xxx.xxx.xxx] Connection idle time: 11 while in state: 4 watching for event: 25,close!
    2009-09-07 03:02:42.006 [NOTICE] [64.127.102.82:17873-0#APVH_xxx.xxx.xxx] Content len: 0, Request line:
    2009-09-07 03:02:42.006 [NOTICE] [64.127.102.82:17873-0#APVH_xxx.xxx.xxx] Redirect: #1, URL: /blog/index.php
    2009-09-07 03:05:14.699 [INFO] [62.25.109.195:4123-0#APVH_xxx.xxx.xxx] connection to [/tmp/lshttpd/lsphp5.sock.582] on request #1, confirmed, 0, associated process: 5282, running: 1, error: Connection reset by peer!
    2009-09-07 03:07:17.530 [INFO] [209.249.84.5:51438-0#APVH_xxx.xxx.xxx] connection to [/tmp/lshttpd/lsphp5.sock.582] on request #8, confirmed, 0, associated process: 5282, running: 1, error: Connection reset by peer!
    2009-09-07 03:08:19.849 [INFO] [119.107.82.136:52045-0#APVH_xxx.xxx.xxx] connection to [/tmp/lshttpd/lsphp5.sock.582] on request #15, confirmed, 0, associated process: 5282, running: 1, error: Connection reset by peer!
    2009-09-07 03:09:56.439 [INFO] [195.88.32.160:2184-0#APVH_xxx.xxx.xxx] Connection idle time: 11 while in state: 4 watching for event: 25,close!
    2009-09-07 03:09:56.439 [NOTICE] [195.88.32.160:2184-0#APVH_xxx.xxx.xxx] Content len: 555, Request line:
    POST /wp-comments-post.php HTTP/1.1


    Any ideas what could have caused such a dramatic issue?
  12. auser

    auser Super Moderator

    have you tried to disable some wordpress plugins, e.g. W3 total cache, see if any difference?

    for lsphp5(pid=25210) has 320% cpu usage, can trace it to see if it's blocked by whatever system call:

    ~>strace -c -p 25210

    run it for some seconds, then Ctrl+C, to check the output.
  13. canglan

    canglan New Member

    Hi auser, thanks for the tips. We are actually working with the author of W3 Total Cache to solve some potential issues.

    Unfortunately we can't trace that pid because the server was completely dead and we had to switch it to rescue mode and bring it back. By then the process was no longer exist.
  14. canglan

    canglan New Member

    Looks like there wasn't enough memory allocated to lsphp5, I didn't realise APC shm size is counted towards the memory limit. I have increased the memory limit now and hopefully this problem will go away. :)

Share This Page