Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a VPS running Ubuntu 11.04 server, every week or so I have to reboot it as (I think) it's run out of memory.

It has 256MB of RAM available and I've tried configuring Apache to run less RAM-heavy but to no avail.

Can you advise what my next course of action should be? I'm guessing there's a log somewhere that'll tell me what happened and when, where can I find that?


Edit:

I think it's running out of memory because I remember seeing error messages when I log in via my serial console (when it crashes I can't SSH, etc). I can't remember the messages exactly but it said something about unable to create apache process - kill PID something or other (sorry to be so vague!).

Here's the output from top...

top - 09:42:40 up 16:10,  1 user,  load average: 0.01, 0.11, 0.12
Tasks:  78 total,   1 running,  77 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.2%us,  0.0%sy,  0.0%ni, 99.8%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:    244284k total,   230528k used,    13756k free,     3348k buffers
Swap:   262140k total,   191868k used,    70272k free,    63008k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 1079 www-data  20   0  322m  26m  276 S  0.0 11.1   0:02.78 apache2
 1072 www-data  20   0  260m  26m  192 S  0.0 10.9   0:02.49 apache2
  877 www-data  20   0  255m  25m  140 S  0.0 10.6   0:02.89 apache2
  872 www-data  20   0  249m  22m  200 S  0.0  9.6   0:02.93 apache2
  875 www-data  20   0  263m  10m  132 S  0.0  4.4   0:03.53 apache2
 1141 www-data  20   0  267m 9.8m  172 S  0.0  4.1   0:02.81 apache2
  451 mysql     20   0  241m 2296   68 S  0.0  0.9   0:21.08 mysqld
  923 www-data  20   0  263m 2188   44 S  0.0  0.9   0:03.10 apache2
 1865 root      20   0 18232 2088 1380 S  0.0  0.9   0:00.05 bash
  924 www-data  20   0  252m 2012  256 S  0.0  0.8   0:02.90 apache2
 1852 root      20   0 93524 1940  980 S  0.0  0.8   0:00.11 sshd
 1077 www-data  20   0  252m 1824  128 S  0.0  0.7   0:01.58 apache2
 1171 www-data  20   0  228m 1640  216 S  0.0  0.7   0:01.68 apache2
  833 root      20   0  207m 1432  268 S  0.0  0.6   0:02.19 apache2
 2053 root      20   0 19352 1268  948 R  0.3  0.5   0:00.02 top
 1805 postfix   20   0 39428 1160  708 S  0.0  0.5   0:00.01 pickup
    1 root      20   0 23980  808  304 S  0.0  0.3   0:00.27 init
  397 syslog    20   0 54452  600  460 S  0.0  0.2   0:00.27 rsyslogd
  390 root      20   0 49464  436  260 S  0.0  0.2   0:00.01 sshd
  934 postfix   20   0 41944  380  232 S  0.0  0.2   0:00.05 tlsmgr
  638 root      20   0 37364  372  272 S  0.0  0.2   0:00.22 master
  801 proftpd   20   0 98.5m  328  228 S  0.0  0.1   0:00.38 proftpd
  646 postfix   20   0 39592  300  236 S  0.0  0.1   0:00.06 qmgr
  437 root      20   0 18928  280  196 S  0.0  0.1   0:00.16 cron
  244 root      18  -2 21268  152  148 S  0.0  0.1   0:00.00 udevd
  421 root      20   0  6196  136  132 S  0.0  0.1   0:00.00 getty
  422 root      20   0  6196  136  132 S  0.0  0.1   0:00.00 getty
  426 root      20   0  6196  136  132 S  0.0  0.1   0:00.00 getty
  428 root      20   0  6196  136  132 S  0.0  0.1   0:00.00 getty
  431 root      20   0  6196  136  132 S  0.0  0.1   0:00.00 getty
  864 root      20   0  6196  136  132 S  0.0  0.1   0:00.00 getty
  866 root      20   0  6196  136  132 S  0.0  0.1   0:00.00 getty
  198 root      16  -4 21280  124  120 S  0.0  0.1   0:00.03 udevd
  246 root      18  -2 21144  116  112 S  0.0  0.0   0:00.00 udevd
  541 memcache  20   0 63008   80   80 S  0.0  0.0   0:02.08 memcached
  727 root      20   0 54764   80   76 S  0.0  0.0   0:00.00 saslauthd
  438 daemon    20   0 16728   64   64 S  0.0  0.0   0:00.00 atd
  316 root      20   0 15004    4    0 S  0.0  0.0   0:00.01 upstart-socket-
  728 root      20   0 54764    4    0 S  0.0  0.0   0:00.00 saslauthd
  729 root      20   0 54764    4    0 S  0.0  0.0   0:00.00 saslauthd
  730 root      20   0 54764    4    0 S  0.0  0.0   0:00.00 saslauthd
  731 root      20   0 54764    4    0 S  0.0  0.0   0:00.00 saslauthd
    2 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthreadd
    3 root      20   0     0    0    0 S  0.0  0.0   0:00.76 ksoftirqd/0
    4 root      20   0     0    0    0 S  0.0  0.0   0:01.24 kworker/0:0
    5 root      20   0     0    0    0 S  0.0  0.0   0:00.16 kworker/u:0
    6 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0
    7 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 cpuset
    8 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 khelper
    9 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 netns
   10 root      20   0     0    0    0 S  0.0  0.0   0:00.00 xenwatch
   11 root      20   0     0    0    0 S  0.0  0.0   0:00.00 xenbus
   12 root      20   0     0    0    0 S  0.0  0.0   0:00.07 sync_supers

The server is running fine at the minute - I only know something has happened when I can't access FTP or MySQL.

share|improve this question
    
Why do you think it's run out of memory? What's the symptom? –  David Schwartz Mar 13 '12 at 9:33
add comment

2 Answers 2

Well it depends on what type of sites you are running on your Apache. I have had websites with picture galleries on them crash with 512 MB of memory. You should do a test, setup a similar setup, install a graphing tool like munin, and start visiting your website. You can see where you generate load.

If it's not that, but you see a graph that keeps growing up exponentially, you might have a memory leak.

share|improve this answer
add comment

If you've run out of memory, you will see OOM killer messages in /var/log/messages. Check that log after an incident.

As to what's using up memory, that's hard to say without more details on your setup. You can always run, say, top and sort by mem usage to have a quick look at what's going on.

share|improve this answer
    
Looking at your updated post: get a bigger service tier for your VPS. You can try to reduce the number of Apache workers, also, but I don't think it'll make a big enough difference over the long haul. –  cjc Mar 13 '12 at 9:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.