Link to home
Create AccountLog in
Avatar of U_S_A
U_S_A

asked on

Apache using too much memory

apache process is using allot of memory.  

any suggestions how to make it use less memory?

centos
whm/cpanel


top - 16:48:08 up 1 day, 23:20,  1 user,  load average: 0.64, 0.66, 0.62
Tasks: 1077 total,   2 running, 1075 sleeping,   0 stopped,   0 zombie
Cpu(s):  1.0%us,  0.9%sy,  0.0%ni, 98.1%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:  66092388k total, 20597876k used, 45494512k free,  1252612k buffers
Swap: 34097136k total,        0k used, 34097136k free, 13959548k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
73397 nobody    20   0 2020m  11m 2580 S  2.6  0.0   0:34.07 httpd
 5948 nobody    20   0 2020m  11m 2580 S  1.0  0.0   0:24.98 httpd
73474 nobody    20   0 2020m  11m 2580 S  1.0  0.0   0:33.84 httpd
73294 nobody    20   0 2020m  11m 2580 S  0.7  0.0   0:32.51 httpd
73295 nobody    20   0 2020m  11m 2580 S  0.7  0.0   0:41.07 httpd
73296 nobody    20   0 2020m  11m 2552 S  0.7  0.0   0:32.65 httpd
73430 nobody    20   0 2020m  10m 2272 S  0.7  0.0   0:31.80 httpd
73646 nobody    20   0 2020m  11m 2592 S  0.7  0.0   0:37.01 httpd
74196 nobody    20   0 2020m  10m 2280 S  0.7  0.0   0:31.01 httpd
23416 nobody    20   0 2020m  10m 2232 S  0.3  0.0   0:09.55 httpd
73286 nobody    20   0 88980 2952  968 S  0.0  0.0   0:00.00 httpd

Open in new window


Avatar of Jayachandran Palanisamy
Jayachandran Palanisamy
Flag of India image

Hi,
Please let me know the following things.
1.ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS
2.free -m
3.What type of Website that you are running with? Is it using mysql?
4.Have you done apache tweaking before if yes list out the values that you have tweaked.

-Jay
ASKER CERTIFIED SOLUTION
Avatar of xterm
xterm

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
I agree with xterm's analysis

Using top, you could press the following keys :
F
n
<enter>

to sort your processes by memory consumption. You'll quickly see who's eating 22 GB (WOW :))

Running top, press ? to see the internal commands (sort, filters and so on)
Avatar of U_S_A
U_S_A

ASKER

I rebuilt apache and php via the easyapache in WHM

I removed numerous non-needed modules

I ended up with this as a result

btw, I plan to add 1 or 2 more sites to this server -- which will use mysql and apache heavily

top - 15:45:59 up 2 days, 22:18,  5 users,  load average: 1.56, 1.51, 1.00
Tasks: 1187 total,   1 running, 1185 sleeping,   0 stopped,   1 zombie
Cpu(s):  0.6%us,  0.3%sy,  0.0%ni, 98.7%id,  0.3%wa,  0.0%hi,  0.1%si,  0.0%st
Mem:  66092388k total, 23903800k used, 42188588k free,  1090928k buffers
Swap: 34097136k total,        0k used, 34097136k free,  7671436k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
34706 nobody    20   0 79732 4024 1928 S  0.3  0.0   0:00.06 httpd
36141 nobody    20   0 79732 3964 1908 S  0.3  0.0   0:00.01 httpd
36172 nobody    20   0 79732 3992 1928 S  0.3  0.0   0:00.02 httpd
36173 nobody    20   0 79732 3964 1924 S  0.3  0.0   0:00.01 httpd
36242 nobody    20   0 79732 3980 1928 S  0.3  0.0   0:00.01 httpd
36702 nobody    20   0 79732 3952 1916 S  0.3  0.0   0:00.01 httpd
32382 nobody    20   0 79732 4020 1932 S  0.0  0.0   0:00.23 httpd
32612 nobody    20   0 79732 4036 1932 S  0.0  0.0   0:00.28 httpd
33260 nobody    20   0 79732 4028 1936 S  0.0  0.0   0:00.16 httpd
33454 nobody    20   0 79732 4028 1932 S  0.0  0.0   0:00.10 httpd
34731 nobody    20   0 79732 3976 1928 S  0.0  0.0   0:00.04 httpd
34745 nobody    20   0 79732 3984 1932 S  0.0  0.0   0:00.04 httpd
34746 nobody    20   0 79732 3980 1916 S  0.0  0.0   0:00.05 httpd
34749 nobody    20   0 79732 4000 1932 S  0.0  0.0   0:00.06 httpd
35080 nobody    20   0 79732 4124 2048 S  0.0  0.0   0:00.06 httpd
35123 nobody    20   0 79732 3964 1916 S  0.0  0.0   0:00.03 httpd
35131 nobody    20   0 79732 3984 1928 S  0.0  0.0   0:00.04 httpd
35134 nobody    20   0 79728 4004 1920 S  0.0  0.0   0:00.04 httpd
35153 nobody    20   0 79732 3992 1932 S  0.0  0.0   0:00.04 httpd
35160 nobody    20   0 79732 4000 1916 S  0.0  0.0   0:00.04 httpd
35167 nobody    20   0 79732 3996 1928 S  0.0  0.0   0:00.04 httpd
35173 nobody    20   0 79732 3996 1928 S  0.0  0.0   0:00.04 httpd
35360 nobody    20   0 79732 3980 1928 S  0.0  0.0   0:00.03 httpd
35370 nobody    20   0 79732 3980 1924 S  0.0  0.0   0:00.01 httpd
35371 nobody    20   0 79728 3968 1916 S  0.0  0.0   0:00.03 httpd
35372 nobody    20   0 79732 3956 1912 S  0.0  0.0   0:00.02 httpd
35376 nobody    20   0 79732 3984 1916 S  0.0  0.0   0:00.02 httpd
35377 nobody    20   0 79732 3992 1920 S  0.0  0.0   0:00.03 httpd
35401 nobody    20   0 79732 4044 1932 S  0.0  0.0   0:00.03 httpd
35403 nobody    20   0 79732 4000 1932 S  0.0  0.0   0:00.03 httpd
35547 nobody    20   0 79732 3988 1928 S  0.0  0.0   0:00.03 httpd
35562 nobody    20   0 79732 3980 1912 S  0.0  0.0   0:00.04 httpd
35566 nobody    20   0 79732 4016 1928 S  0.0  0.0   0:00.02 httpd
35591 nobody    20   0 79732 4000 1928 S  0.0  0.0   0:00.03 httpd
35594 nobody    20   0 79732 3984 1924 S  0.0  0.0   0:00.02 httpd
35615 nobody    20   0 79732 4028 1916 S  0.0  0.0   0:00.03 httpd
35687 nobody    20   0 79732 3984 1928 S  0.0  0.0   0:00.03 httpd
35694 nobody    20   0 79732 3976 1928 S  0.0  0.0   0:00.02 httpd
35806 nobody    20   0 79732 3996 1928 S  0.0  0.0   0:00.03 httpd
35807 nobody    20   0 79732 3992 1932 S  0.0  0.0   0:00.01 httpd
35817 nobody    20   0 79732 4020 1920 S  0.0  0.0   0:00.01 httpd
35827 nobody    20   0 79732 3948 1916 S  0.0  0.0   0:00.00 httpd
35829 nobody    20   0 79732 3980 1912 S  0.0  0.0   0:00.00 httpd
35831 nobody    20   0 79732 4040 1928 S  0.0  0.0   0:00.02 httpd
35841 nobody    20   0 79732 4024 1932 S  0.0  0.0   0:00.02 httpd
35842 nobody    20   0 79732 3920 1896 S  0.0  0.0   0:00.00 httpd

Open in new window

I see you got a fairly nice improvement, but memory is cheap these days - we don't have to squeeze every last bit of blood out of that rock like we all used to back in the day when we were running web servers on i386 machines with like 32MB RAM :)

Good for you for streamlining it though!
Avatar of U_S_A

ASKER

We expect the number of apache processes to triple with the next site we bring onto this server.
Wow, time to think about a load balancer in front of a cluster of Apache servers!
Avatar of U_S_A

ASKER

How difficult is that?
Not at all difficult...but can be expensive.
Hello.
Haproxy can be a good solution for a "cheap" load balancer.