high memory usage due to wordpress?

having a funny issue here where my sites will randomly crash. Memory utilization is high and at times Apache needs restarted.

My host states that apache is already optimized and I should optimize the php scripts under my accounts (wordpress is the only script running)

Any ideas as to how I would accomplish that?

load was high at 5.40 PM.


03:50:01 PM 1 116 0.53 0.51 0.46
04:00:01 PM 1 138 0.26 0.54 0.50
04:10:01 PM 3 165 0.38 0.46 0.47
04:20:01 PM 2 138 0.55 0.56 0.51
04:30:01 PM 6 133 0.37 0.40 0.43
04:40:01 PM 2 118 0.67 0.62 0.51
04:50:01 PM 1 106 0.62 0.50 0.46
05:00:01 PM 1 134 0.43 0.46 0.44
05:10:01 PM 2 123 0.35 0.50 0.47
05:20:01 PM 1 127 0.62 0.57 0.49
05:30:01 PM 4 145 0.45 0.44 0.45
05:40:01 PM 149 236 73.54 20.09 7.20
05:50:01 PM 2 143 1.83 38.71 34.32
06:00:01 PM 2 162 0.73 5.90 18.35
Average: 3 116 1.05 0.95 0.87
root@host [~]#

I have checked the log file at that time and found that Apache was taking maximum resources.


top – 17:40:31 up 41 days, 15:43, 0 users, load average: 102.92, 32.32, 11.67
Tasks: 181 total, 150 running, 31 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.7%us, 0.3%sy, 0.2%ni, 98.8%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 1310720k total, 921964k used, 388756k free, 0k buffers
Swap: 0k total, 0k used, 0k free, 0k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
16239 nobody 25 0 53560 32m 15m R 58.2 2.5 0:29.41 /usr/local/apache/b
16326 nobody 25 0 46168 12m 3548 R 15.5 1.0 0:13.62 /usr/local/apache/b
17414 nobody 25 0 49260 20m 8912 R 15.5 1.6 0:12.75 /usr/local/apache/b
16052 nobody 25 0 51988 29m 14m R 13.6 2.3 0:09.26 /usr/local/apache/b
16054 nobody 25 0 54068 32m 15m R 13.6 2.6 0:11.65 /usr/local/apache/b
16256 nobody 25 0 51988 30m 15m R 13.6 2.4 0:11.09 /usr/local/apache/b
16282 nobody 25 0 53304 26m 10m R 13.6 2.1 0:09.87 /usr/local/apache/b
16293 nobody 25 0 51492 29m 14m R 13.6 2.3 0:09.25 /usr/local/apache/b
16327 nobody 25 0 46300 12m 3576 R 13.6 1.0 0:11.77 /usr/local/apache/b
16331 nobody 25 0 51988 24m 9352 R 13.6 1.9 0:11.75 /usr/local/apache/b

BUMP.

wordpress is killing my server

100% CPU LOAD
92% MEMORY UTILIZATION

once I restart Apache, the CPU load drops back down to OK numbers but the memory usage remains above 50%

i had this on my hostgator account. I first installed cleanoptions, removed anything it found that I didn’t need. Then installed WTC and everything has been smooth since.

Backup everything first

it’s not going to do much though until you resolve the issue.

w3totalcache will help to keep PHP from spawning, but from your top output it doesn’t look like it’s a PHP issue directly, but apache.

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
16239 nobody 25 0 53560 32m 15m R 58.2 2.5 0:29.41 /usr/local/apache/b
16326 nobody 25 0 46168 12m 3548 R 15.5 1.0 0:13.62 /usr/local/apache/b
17414 nobody 25 0 49260 20m 8912 R 15.5 1.6 0:12.75 /usr/local/apache/b
16052 nobody 25 0 51988 29m 14m R 13.6 2.3 0:09.26 /usr/local/apache/b
16054 nobody 25 0 54068 32m 15m R 13.6 2.6 0:11.65 /usr/local/apache/b
16256 nobody 25 0 51988 30m 15m R 13.6 2.4 0:11.09 /usr/local/apache/b
16282 nobody 25 0 53304 26m 10m R 13.6 2.1 0:09.87 /usr/local/apache/b
16293 nobody 25 0 51492 29m 14m R 13.6 2.3 0:09.25 /usr/local/apache/b
16327 nobody 25 0 46300 12m 3576 R 13.6 1.0 0:11.77 /usr/local/apache/b

Your CPUs *show* 98% idle, but I bet this snapshot was taken as the primary load issue was gone or something similar.

Memory usage for Linux should really be as much as possible. We run our farm as close to 99% memory usage as possible for disk caching, as the kernel will free up memory and re-add cache as needed, so don’t be alarmed with low free memory. *DO* be alarmed if you are actively using SWAP though. SWAP is usually a physical partition of your HDD, so writing memory shit to the disk is very I/O intensive.

I recommend having an admin looking at your box. I can take a look if you like, I work for a major hosting company so we might even host your site 😛 :shrug:

Half-Time, this is what I typically see:

I’m trying what Browning suggested right now but wouldn’t mind someone looking into my box

i had this on my hostgator account. I first installed cleanoptions, removed anything it found that I didn’t need. Then installed WTC and everything has been smooth since.

Backup everything first

does cleanoptions make a big difference?

that and removing unneeded things from the database got hostgator off my back for a few different sites

might give it a try on one of my less important WP installations

, my one biggest fear using wordpress is that happening. Has happened once years and years ago.
First thing I do when installing new ones, is remove everything, extra plugins, images, pages, etc strip it down as much as possible..

Is this a shared server? Caching will help the load from mysql and php, not so much Apache. Are you getting slammed with traffic at these times?

I would honestly have the host look into it. If you have hostgator you are lucky, their techs are awesome. but rather than email them, call in. the difference is amazing.

Drop me a PM if you’re still having issues, ill see if I can help

Is this a shared server? Caching will help the load from mysql and php, not so much Apache. Are you getting slammed with traffic at these times?

I would honestly have the host look into it. If you have hostgator you are lucky, their techs are awesome. but rather than email them, call in. the difference is amazing.

its a VPS. I contacted the host and they sent it back stating it was our scripts. Apache is slaughtering our memory leaving us with less then 32mb free.

I wouldn’t say slammed with traffic, we’ve had better days but around 250-300 simultaneous connections and it starts. 180 processes around 177 of them sleeping (is that normal?)

PMed