Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2002
    Location
    Sibiu, Romania
    Posts
    229

    Apache KeepAlive setings

    Hello,

    I've been dealing with some problems in the last months, first problem was about the Mysql CPU usage, was realy high. After I have optimized alittle some tables I have resolved this issue. The server runs smoth with a single exception, when I get lots of RRRRRRRRRRRRRRR requests in apache status, basicaly the RRRR uses all the 200 apache conections.

    Also I think my main website is not loading as fast as it should. (open homepage)

    Now I was searching on optimizing the server and I see the KeepAlive is off.

    My main website (2500 unique visitors/day) homepage has 123 elements in it (images, css and js files) and teoreticaly the keepalive set ON (timeout 2 seconds) it should help .
    I'm wright ?

    WHM APACHE STATUS PAGE
    Current Time: Tuesday, 06-May-2008 12:03:54 EDT
    Restart Time: Tuesday, 06-May-2008 07:35:25 EDT
    Parent Server Generation: 7
    Server uptime: 4 hours 28 minutes 29 seconds
    Total accesses: 304742 - Total Traffic: 1.9 GB
    CPU Usage: u3966.41 s338.39 cu.24 cs.26 - 26.7% CPU load
    18.9 requests/sec - 124.1 kB/second - 6.6 kB/request
    14 requests currently being processed, 45 idle servers

    -----------------------------------------

    WHM Service Status

    Server Load 1.68 (4 cpus)
    Memory Used 47.1 %
    Swap Used 3.82 %

    -----------------------------------------

    top - 12:13:44 up 34 days, 6:14, 1 user, load average: 0.90, 1.10, 1.03
    Tasks: 149 total, 1 running, 148 sleeping, 0 stopped, 0 zombie
    Cpu(s): 27.3% us, 2.2% sy, 0.0% ni, 67.1% id, 1.9% wa, 1.6% hi, 0.0% si
    Mem: 2074364k total, 2034496k used, 39868k free, 116304k buffers
    Swap: 2096440k total, 79900k used, 2016540k free, 972628k cached

    PID USER PR NI %CPU TIME+ %MEM VIRT RES SHR S COMMAND
    21927 nobody 15 0 15 0:02.16 0.8 34664 16m 3244 S httpd
    29446 mysql 15 0 15 30:10.05 7.2 300m 144m 3808 S mysqld
    29576 nobody 16 0 12 4:55.15 1.0 38728 21m 4340 S httpd
    29578 nobody 15 0 9 5:38.88 1.0 37884 20m 4688 S httpd
    29588 nobody 15 0 8 6:54.26 1.2 42768 24m 4708 S httpd
    21892 nobody 15 0 8 0:04.47 0.8 34184 16m 3988 S httpd
    21889 nobody 15 0 6 0:03.52 0.8 33960 16m 3888 S httpd
    22003 nobody 15 0 6 0:00.44 0.8 31288 15m 3112 S httpd
    21823 nobody 16 0 5 0:07.37 0.9 36884 18m 3360 S httpd
    21910 nobody 15 0 4 0:03.68 0.9 35512 17m 3904 S httpd
    21922 nobody 15 0 4 0:02.28 0.8 33816 15m 3264 S httpd
    21888 nobody 15 0 4 0:02.70 0.8 33916 15m 3244 S httpd
    21901 nobody 15 0 3 0:03.47 0.8 33840 15m 3284 S httpd
    29574 nobody 15 0 3 6:41.31 1.2 42864 24m 4728 S httpd
    21899 nobody 15 0 3 0:03.88 0.8 33912 15m 3364 S httpd
    22002 nobody 15 0 3 0:00.34 0.8 33732 15m 3196 S httpd
    29575 nobody 16 0 3 4:50.70 1.1 39912 22m 5184 S httpd
    21890 nobody 15 0 2 0:04.45 0.8 34132 16m 4028 S httpd
    21495 nobody 16 0 1 0:13.57 0.8 34732 17m 4060 S httpd
    22011 admin 16 0 1 0:00.02 0.1 2132 1044 780 R top
    477 root 15 0 0 14:30.45 0.0 0 0 0 S kjournald
    21993 nobody 15 0 0 0:00.97 0.9 36244 17m 5064 S httpd
    29875 root 16 0 0 1:26.26 0.2 6444 5032 2712 S authProg
    1 root 16 0 0 2:34.74 0.0 2028 464 436 S init
    2 root RT 0 0 0:41.75 0.0 0 0 0 S migration/0
    3 root 34 19 0 0:02.41 0.0 0 0 0 S ksoftirqd/0
    4 root RT 0 0 3:14.35 0.0 0 0 0 S migration/1
    5 root 34 19 0 0:02.76 0.0 0 0 0 S ksoftirqd/1
    6 root RT 0 0 7:31.58 0.0 0 0 0 S migration/2
    7 root 34 19 0 0:04.85 0.0 0 0 0 S ksoftirqd/2
    8 root RT 0 0 1:57.35 0.0 0 0 0 S migration/3
    9 root 34 19 0 0:01.93 0.0 0 0 0 S ksoftirqd/3

  2. #2
    All those R connections are the result of a denial-of-service attack, or maybe just very high usage but this is less likely.

    If it is a DoS attack then you either need to find a way of stopping the attack, or at least a way to stop the attack taking up all of your resource intensive apache processes. I don't know for sure but I think that Pound (a reverse proxy) reads the entire request before sending it on to Apache, so each of these DoS connections would tie up an extremely light weight Pound thread, not an Apache one. You might want to give this a try as it might enable you to handle far more bad connections. None of this will be affected by the KeepAlive.

    If you are suffering from too much load from too many genuine connections then the last thing you want to do is enable KeepAlive. If your server is handling load just fine then yes, KeepAlive will help pages load slightly quicker and with slightly less resource usage on the server too. If however the server is reaching the limit of Apache processes that can be spawned then you do not want KeepAlive - those processes should be used to handle requests as fast as possible, not to sit around idly in case something happens on a connection that is probably finished with.

    Jim
    Blue Room Hosting - High availability UK VPS
    KVM Plans - Multiple OS support. Virtual console and CD drive.

  3. #3
    Join Date
    Dec 2002
    Location
    Sibiu, Romania
    Posts
    229
    10x for your reply.

    I have activated keepAlive and for my website it's much better than with KeepAlive Off (my main website is an city portal with lots of content/page).

    It's been almoust 24 hours since keepalive is on and so far the cpuusage is like before .. RAM the same only the number of request has increased, but this is because of the 2 seconds timeout for keepalive.
    I have asked my admin to increase the maximum number of conection too, from 200 to 300

    Current Time: Wednesday, 07-May-2008 08:25:53 EDT
    Restart Time: Tuesday, 06-May-2008 15:15:46 EDT
    Parent Server Generation: 9
    Server uptime: 17 hours 10 minutes 7 seconds
    Total accesses: 784183 - Total Traffic: 4.8 GB
    CPU Usage: u1779.07 s150.86 cu0 cs.01 - 3.12% CPU load
    12.7 requests/sec - 81.1 kB/second - 6.4 kB/request
    32 requests currently being processed, 19 idle servers
    KKKWKKK____W__K_K__KKKKW_K_KKWK_W_K_KK__KW_WK_K.K_KK............
    ................................................................

    Before activating keep alive the number of requests was lower .. like 10 - 20 requests .. now it's around 30.

    In your expirience seting up the timeout to 1 sec will be long enough or to short, it's better to leave it 2 seconds ?
    I have checked the number of elements in the main websites homepage and it's an average of 70 (images/css) / page with minimum of 55 and max of 123.

    For exemple, for the website with 123 elements/page it will be better to setup the MaxKeepAliveRequests to 150 ? than leave it 100 (as it is now)

    Quote Originally Posted by blueroomhosting View Post
    All those R connections are the result of a denial-of-service attack, or maybe just very high usage but this is less likely.
    I will try to read more about POUND http://www.apsis.ch/pound/

    Quote Originally Posted by blueroomhosting View Post
    If you are suffering from too much load from too many genuine connections then the last thing you want to do is enable KeepAlive.
    This is not the problem of my server yet (with the exception when RRR appears)

  4. #4
    Join Date
    Nov 2001
    Location
    Philadelphia, Pa
    Posts
    949
    Now I was searching on optimizing the server and I see the KeepAlive is off.

    My main website (2500 unique visitors/day) homepage has 123 elements in it (images, css and js files) and teoreticaly the keepalive set ON (timeout 2 seconds) it should help .
    Generally speaking:
    - Turning KeepAlive on will increase the # of backends in use. In theory it can decrease page load times, but you need to have the resources to open up more backends.
    - Turning KeepAlive off will decrease the # of backends in use. It may not make optimal use of tcp connections, but will allow the backends to finish quicker, and thus use less server resources.

    This is all in theory. In practice, I haven't seen turning KeepAlive's off to have an effect on network efficiency, and unless I have oodles of ram and resources to throw at a web server, I turn KeepAlive's off.

  5. #5
    Join Date
    Dec 2002
    Location
    Sibiu, Romania
    Posts
    229
    Quote Originally Posted by derek.bodner View Post
    This is all in theory. In practice, I haven't seen turning KeepAlive's off to have an effect on network efficiency, and unless I have oodles of ram and resources to throw at a web server, I turn KeepAlive's off.
    This also depends if you have the server located near you and near the moust visitors of your website,

    1. probably if you have an average of 10ms for ping response (this is with a server located in my country) you won't feel the big difference from keepalive ON and OFF ,

    2. but if you have the server located in USA and you are in Europe than the ping response will be ~100ms (this is my case, I am in Romania and the server is in US) and here keepalive makes the difference (as I see it in the last 24 hours)

    I can see there are more requests as before but I don't see significant increase in CPU usage or RAM .. those are just the same as before ( Load Averages: 1.14 1.09 1.27 | Memory Used 52.1 % )

    two of my main websites (bouth with ~ 2500 unique visitors/day) have 90% of the visitors located in romania. I should think of moving the websites on a local server for a higher loading speed.

    PS. please correct me if I'm wrong about the 1. and 2. paragraphs

  6. #6
    Join Date
    Nov 2001
    Location
    Philadelphia, Pa
    Posts
    949
    So if you don't see a significant increase in RAM/CPU, why don't you increase the backends and turn keepalives on?

    Or, better yet, if all your customers are located in one area, get a server close to that area?

  7. #7
    Join Date
    Dec 2002
    Location
    Sibiu, Romania
    Posts
    229
    Quote Originally Posted by derek.bodner View Post
    So if you don't see a significant increase in RAM/CPU, why don't you increase the backends and turn keepalives on?
    I have turned Keepalive ON in the last 24 hours and I intend to keep ip like that as I like the result . Before (in the last 2 years it was set to off)

    Quote Originally Posted by derek.bodner View Post
    Or, better yet, if all your customers are located in one area, get a server close to that area?
    This is the best solution but yet I cant afford 2 dedicated webservers I have other websites too which have moust of visitors from USA

    I try to find the best solution with the hardware I have now.

Posting Permissions

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