Results 1 to 17 of 17
  1. #1
    Join Date
    Jul 2009
    Posts
    78

    Question about apache memory.

    I am using VPS (Linux OS), and web server is apache. I totally have 768M memory. When the system start up, I usually have 550M-600M free memory.

    I just found that each httpd process occupied almost 20M memory. It's horrible, I was though that 1M for each process is reasonable.

    Now the httpd.conf looks like:
    StartServers 5
    MinSpareServers 5
    MaxSpareServers 10
    MaxClients 150


    But if I change StartServers to 50, httpd will eat up all my memory. I did some calculation, that 600M/20M = 30. This means if apache have more than 30 concurrent requests, There server will be out of memory. The "MaxClients 150" is meaningless!!! I was though 150 is too small.

    I only use apache with php, they are complied by WHM. Should I re-complied the apache with php? Any suggestion to resolve this problem?

    Thanks.

  2. #2
    Join Date
    May 2009
    Location
    On a Speck!!!!!
    Posts
    216
    How is Apache compiles in the server ( as prefork module or MPM) ?

    Paste the result of httpd -l.

  3. #3
    Join Date
    Jul 2009
    Posts
    78
    Sorry, I forget that information. I think it's compiled as prefork module. Here is "httpd -l" table.


    [email protected] [/usr/local/apache/conf]# httpd -l
    Compiled in modules:
    core.c
    mod_access.c
    mod_auth.c
    mod_include.c
    mod_log_config.c
    mod_logio.c
    mod_env.c
    mod_expires.c
    mod_headers.c
    mod_setenvif.c
    mod_proxy.c
    proxy_connect.c
    proxy_ftp.c
    proxy_http.c
    mod_ssl.c
    prefork.c
    http_core.c
    mod_mime.c
    mod_status.c
    mod_autoindex.c
    mod_asis.c
    mod_info.c
    mod_suexec.c
    mod_cgi.c
    mod_negotiation.c
    mod_dir.c
    mod_imap.c
    mod_actions.c
    mod_userdir.c
    mod_alias.c
    mod_rewrite.c
    mod_so.c

  4. #4
    Join Date
    May 2009
    Location
    On a Speck!!!!!
    Posts
    216
    Try using the following settings.

    StartServers 8
    MinSpareServers 5
    MaxSpareServers 20
    ServerLimit 256
    MaxClients 256
    MaxRequestsPerChild 4000

    Also make sure the directive "KeepAlive off" is present in your Apacha configuration.

    And consider tweaking Mysql configuration in the server. This will help you a lot.

  5. #5
    Join Date
    Jul 2009
    Posts
    78
    I want to reduce the memory size of each httpd process.

    Changing the Apacha configuration does not helpful at all.

    I did try the "KeepAlive off", and found the memory size of each httpd is still 20M.

    Also, I think if 30 httpd server will eat up all memory, any MaxClients larger than 30 is meaningless.

    I think the only way is re-complied the apache and cut off the useless mod. But I am really not familiar with those apache mod.

  6. #6
    Join Date
    May 2009
    Location
    On a Speck!!!!!
    Posts
    216
    Can you paste the "top" command result here?

  7. #7
    Join Date
    Jul 2009
    Posts
    78
    I do not move my main website to this VPS yet. There is only several small websites on it. I found, besides 20M httpd, there are also some 5M httpd. Here this top result.


    top - 16:08:40 up 2 days, 19:25, 1 user, load average: 0.07, 0.05, 0.07
    Tasks: 82 total, 1 running, 80 sleeping, 0 stopped, 1 zombie
    Cpu(s): 0.1%us, 0.1%sy, 0.0%ni, 99.8%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
    Mem: 786432k total, 419092k used, 367340k free, 0k buffers
    Swap: 0k total, 0k used, 0k free, 0k cached

    PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
    9918 nobody 15 0 111m 5704 1408 S 0.3 0.7 0:00.04 httpd
    32412 nobody 15 0 121m 17m 3156 S 0.3 2.3 0:00.56 httpd
    32418 nobody 15 0 123m 19m 3264 S 0.3 2.5 0:00.79 httpd
    1 root 15 0 10344 728 608 S 0.0 0.1 0:02.51 init
    6068 nobody 15 0 111m 5692 1404 S 0.0 0.7 0:00.00 httpd
    9406 nobody 18 0 111m 5696 1404 S 0.0 0.7 0:00.01 httpd
    9804 root 18 0 103m 38m 2264 S 0.0 5.0 0:01.89 spamd
    9817 root 15 0 103m 37m 1596 S 0.0 4.9 0:09.16 spamd
    9912 nobody 15 0 123m 18m 3688 S 0.0 2.3 0:00.72 httpd
    9984 nobody 15 0 111m 5608 1380 S 0.0 0.7 0:00.00 httpd
    11308 nobody 15 0 121m 17m 3156 S 0.0 2.3 0:00.38 httpd
    11320 nobody 15 0 122m 18m 3300 S 0.0 2.5 0:00.36 httpd
    11322 nobody 15 0 111m 5624 1388 S 0.0 0.7 0:00.03 httpd
    11323 nobody 15 0 122m 17m 3140 S 0.0 2.3 0:00.23 httpd
    11335 nobody 15 0 123m 19m 3432 S 0.0 2.5 0:00.44 httpd
    11339 nobody 18 0 125m 19m 3936 S 0.0 2.6 0:00.35 httpd
    11630 root 18 0 95964 12m 1168 S 0.0 1.7 0:00.76 cpsrvd-ssl
    13602 nobody 15 0 123m 19m 3440 S 0.0 2.5 0:00.82 httpd
    13920 root 15 0 35944 5328 2680 S 0.0 0.7 0:00.22 authProg
    14116 nobody 15 0 113m 7800 3212 S 0.0 1.0 0:00.02 httpd
    14223 nobody 15 0 123m 19m 3404 S 0.0 2.5 0:00.42 httpd
    14224 nobody 15 0 122m 18m 3364 S 0.0 2.5 0:00.30 httpd
    15937 nobody 15 0 111m 5636 1400 S 0.0 0.7 0:00.01 httpd
    15974 nobody 15 0 125m 19m 3836 S 0.0 2.6 0:00.52 httpd
    16079 nobody 18 0 122m 17m 3140 S 0.0 2.3 0:00.19 httpd
    16082 nobody 15 0 122m 18m 3296 S 0.0 2.3 0:00.19 httpd
    17519 nobody 15 0 121m 16m 3168 S 0.0 2.2 0:00.17 httpd
    19678 nobody 15 0 111m 5600 1372 S 0.0 0.7 0:00.00 httpd
    19693 nobody 15 0 111m 5596 1368 S 0.0 0.7 0:00.00 httpd
    19694 nobody 15 0 111m 5596 1368 S 0.0 0.7 0:00.00 httpd

  8. #8
    Join Date
    May 2009
    Location
    On a Speck!!!!!
    Posts
    216
    One last question?

    Are you running php as Apache module in the server.

  9. #9
    Join Date
    Jul 2009
    Posts
    78
    Yes

    LoadModule php5_module modules/libphp5.so

  10. #10
    Join Date
    May 2009
    Location
    On a Speck!!!!!
    Posts
    216
    Check in WHM -> CPU/Memory/MySQL usage. It will show you website name with high httpd usage.

  11. #11
    Join Date
    Jul 2009
    Posts
    78
    I know which website has the highest httpd usage. It's WP blog. I do not think it's a good idea to post URL in this forum.

  12. #12
    Join Date
    Jul 2009
    Posts
    78
    For now the server load is very low....I just do not understand why one apache httpd process need 20M memory.

  13. #13
    Join Date
    May 2009
    Location
    On a Speck!!!!!
    Posts
    216

    *

    Quote Originally Posted by kamanwu View Post
    I know which website has the highest httpd usage. It's WP blog. I do not think it's a good idea to post URL in this forum.
    Yeah. That's true.

    Did you try tweaking your Mysql configuration?

  14. #14
    Join Date
    Dec 2006
    Posts
    477
    Apache is a memory hog but a lot of that 20M is going to be the php interpreter. Probably the 5M processes have never served a php request so don't have it loaded into memory and the 20M processes do. However, where it shows 20M per process, some of that is shared memory between all of them - it doesn't mean they all have their own unique 20M allocated.

    In limited memory situations you are better switching to a copy of apache compiled with the worker mpm and php running as fastcgi backend rather than mod_php.

  15. #15
    Join Date
    Jul 2009
    Posts
    78
    Quote Originally Posted by RBBOT View Post
    Apache is a memory hog but a lot of that 20M is going to be the php interpreter. Probably the 5M processes have never served a php request so don't have it loaded into memory and the 20M processes do. However, where it shows 20M per process, some of that is shared memory between all of them - it doesn't mean they all have their own unique 20M allocated.

    In limited memory situations you are better switching to a copy of apache compiled with the worker mpm and php running as fastcgi backend rather than mod_php.

    Thanks for the suggestion. Can I do this by WHM/Easy Apache??

  16. #16
    Join Date
    Jul 2009
    Posts
    78
    Quote Originally Posted by RBBOT View Post
    Apache is a memory hog but a lot of that 20M is going to be the php interpreter. Probably the 5M processes have never served a php request so don't have it loaded into memory and the 20M processes do. However, where it shows 20M per process, some of that is shared memory between all of them - it doesn't mean they all have their own unique 20M allocated.

    In limited memory situations you are better switching to a copy of apache compiled with the worker mpm and php running as fastcgi backend rather than mod_php.

    Also, I want to know, without php interpreter loaded, the 5M httpd is normal or NOT? I thought 5M is still too large.

  17. #17
    Join Date
    Jul 2009
    Posts
    78
    I did some research.
    Since too many mod are Compiled into apache, on average, the httpd is about 5M to 10M. Also the php mod is almost 8M, and it is loaded when necessary. So 20M httpd for processing php file is also reasonable. If you want to reduce the size, you have to re-compiled the apache with less mod, also re-compiled php with less functions. BUT, basically, 20M httpd is not too big. I have saw some httpd bigger than 50M when I do research.

    Now, my problem is that my VPS has tooooooo much CPU(8 cpus), but toooooo less RAM(768M). By calculation, the MAX httpd number should around 120-180. If I need MaxClients 250, I have to double my memory.

    For now, my CPU load is below 0.5, but I am already out of memory!!!

Similar Threads

  1. how we can up the Apache Memory Usage
    By ahbahouse in forum VPS Hosting
    Replies: 3
    Last Post: 11-20-2008, 09:14 PM
  2. Apache PHP memory consumption
    By marco in forum Dedicated Server
    Replies: 4
    Last Post: 12-23-2007, 06:11 AM
  3. apache memory problems
    By Bono_ in forum Hosting Security and Technology
    Replies: 12
    Last Post: 09-25-2007, 09:29 AM
  4. Apache loading memory
    By Dimka in forum Hosting Security and Technology
    Replies: 2
    Last Post: 12-25-2005, 11:35 PM
  5. Apache consuming a lot of memory
    By pita in forum Hosting Security and Technology
    Replies: 2
    Last Post: 01-26-2002, 04:04 AM

Posting Permissions

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