Score:0

Apache crashing because of high memory usage

th flag
  CPU[||||                                                    3.3%]     Tasks: 71, 155 thr; 1 running
  Mem[|||||||||||||||||||||||||||||||||||||||||||||||||1261/1875MB]     Load average: 0.00 0.02 0.01 
  Swp[                                                       0/0MB]     Uptime: 02:17:35

  PID USER      PRI  NI  VIRT   RES   SHR S CPU% MEM%   TIME+  Command
 2385 centos     20   0  110M  2136  1228 R 14.3  0.1  0:00.01 htop
    1 root       20   0 19232  1532  1240 S  0.0  0.1  0:01.77 /sbin/init
  372 root       16  -4 10764   888   348 S  0.0  0.0  0:00.05 /sbin/udevd -d
  584 root       18  -2 10628   756   348 S  0.0  0.0  0:00.00 /sbin/udevd -d
  937 root       20   0  9116  1004   512 S  0.0  0.1  0:00.00 /sbin/dhclient -H staging -1 -q -cf /etc/dhcp/dhclient-eth0.conf -lf /var/lib/
  994 root       16  -4 29764   840   596 S  0.0  0.0  0:00.00 auditd
  993 root       16  -4 29764   840   596 S  0.0  0.0  0:00.03 auditd
 1016 root       20   0  243M  1652  1068 S  0.0  0.1  0:00.00 /sbin/rsyslogd -i /var/run/syslogd.pid -c 5
 1018 root       20   0  243M  1652  1068 S  0.0  0.1  0:00.00 /sbin/rsyslogd -i /var/run/syslogd.pid -c 5
 1019 root       20   0  243M  1652  1068 S  0.0  0.1  0:00.00 /sbin/rsyslogd -i /var/run/syslogd.pid -c 5
 1015 root       20   0  243M  1652  1068 S  0.0  0.1  0:00.02 /sbin/rsyslogd -i /var/run/syslogd.pid -c 5
 1042 redis      20   0  136M  5384  1040 S  0.0  0.3  0:00.00 /usr/bin/redis-server 127.0.0.1:6379
 1043 redis      20   0  136M  5384  1040 S  0.0  0.3  0:00.00 /usr/bin/redis-server 127.0.0.1:6379
 1038 redis      20   0  136M  5384  1040 S  0.0  0.3  0:07.41 /usr/bin/redis-server 127.0.0.1:6379
 1052 dbus       20   0 21432   884   636 S  0.0  0.0  0:00.00 dbus-daemon --system
 1090 root       20   0  4076   640   528 S  0.0  0.0  0:00.00 /usr/sbin/acpid
 1226 memcached  20   0  323M   880   528 S  0.0  0.0  0:00.00 memcached -d -p 11211 -u memcached -m 256 -c 1024 -P /var/run/memcached/memcac
 1227 memcached  20   0  323M   880   528 S  0.0  0.0  0:00.00 memcached -d -p 11211 -u memcached -m 256 -c 1024 -P /var/run/memcached/memcac
 1228 memcached  20   0  323M   880   528 S  0.0  0.0  0:00.00 memcached -d -p 11211 -u memcached -m 256 -c 1024 -P /var/run/memcached/memcac
 1229 memcached  20   0  323M   880   528 S  0.0  0.0  0:00.00 memcached -d -p 11211 -u memcached -m 256 -c 1024 -P /var/run/memcached/memcac
 1230 memcached  20   0  323M   880   528 S  0.0  0.0  0:00.00 memcached -d -p 11211 -u memcached -m 256 -c 1024 -P /var/run/memcached/memcac
 1223 memcached  20   0  323M   880   528 S  0.0  0.0  0:00.22 memcached -d -p 11211 -u memcached -m 256 -c 1024 -P /var/run/memcached/memcac
 1245 root       20   0 66288  1200   468 S  0.0  0.1  0:00.00 /usr/sbin/sshd
 1256 ntp        20   0 30740  2148  1536 S  0.0  0.1  0:00.03 ntpd -u ntp:ntp -p /var/run/ntpd.pid -g
 1286 root       20   0  105M  1672  1340 S  0.0  0.1  0:00.00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysq
 1378 mysql      20   0  9.6G  871M 14300 S  0.0 46.5  0:00.00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib
 1379 mysql      20   0  9.6G  871M 14300 S  0.0 46.5  0:00.00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib
 1382 mysql      20   0  9.6G  871M 14300 S  0.0 46.5  0:00.22 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib
 1383 mysql      20   0  9.6G  871M 14300 S  0.0 46.5  0:00.20 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib
 1384 mysql      20   0  9.6G  871M 14300 S  0.0 46.5  0:00.16 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib
 1385 mysql      20   0  9.6G  871M 14300 S  0.0 46.5  0:00.17 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib
 1386 mysql      20   0  9.6G  871M 14300 S  0.0 46.5  0:00.28 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib

Apache is crashing because of high memory usage, but I am not 100% sure, because there's still some memory left and it's not using 100% of the RAM. However, it's using a lot of virtual memory for some reason, which tells me there might be a lack of RAM. How do you get to the root cause of what's calling the MYSQL process? I need to find the exact php line that's responsible of the large amount of memory being spent. Also, is there a way to make sure that it's the MYSQL process that's causing Apache to shut down at some point? How do you take a process, and then trace back to the exact code that's causing this?

Michael Hampton avatar
cz flag
Apache isn't even in this list. Where are you finding stats for it?
ua flag
Redis + Memcached + MySQL living together in 2GB with no swap? I'm not surprised that it crashed. Let's see `my.cnf`; there may be some settings that are too high.
Wilson Hauck avatar
jp flag
Is there a reason to have two copies of auditd listed in your htop report? SHOW FULL PROCESSLIST; will have PID's listed that directly relate to first column of htop report and include the query running when SHOW FULL PROCESSLIST was requested.
Wilson Hauck avatar
jp flag
Consider enabling 6GB swap space to allow survival when busy. So what if things are slow for some number of seconds? Better to finsh the processing than terminate with OOM.
biwiga avatar
th flag
How do you enable 6GB swap space on an EC2 instance?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.