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 (unmanaged, Ubuntu 10.04.3 LTS) which seems to crash every few days. I am fairly sure it is caused by Apache2, since restarting the service (when I get the chance) does address the issue.

Right before the machine crashes, the server will bog down to the point you can't even type any commands anymore, but my SSH connection is still alive, and once in a while, a character will go through.

I am guessing it might be memory related, however I had an identical configuration on a 'lesser' machine before I moved to this VPS, and never had any problems. Hopefully someone can help figure out the source of this problem.

free output:

                 total       used       free     shared    buffers     cached
    Mem:       1754060    1708164      45896          0      25372     138436
    -/+ buffers/cache:    1544356     209704
    Swap:      1959924      97616    1862308

ps -auxw | grep apache2 output:

    root       845  0.0  3.9 402300 68536 ?        Ss   07:13   0:01 /usr/sbin/apache2 -k start
    www-data  1366  0.4  6.5 445084 115336 ?       S    07:38   1:58 /usr/sbin/apache2 -k start
    www-data  1524  0.3  6.4 442536 112524 ?       S    07:44   1:53 /usr/sbin/apache2 -k start
    www-data  4219  0.4  6.4 441244 112876 ?       S    10:22   1:27 /usr/sbin/apache2 -k start
    www-data  4571  0.4  6.1 438284 108632 ?       S    10:42   1:13 /usr/sbin/apache2 -k start
    www-data  5476  0.4  6.3 441448 111252 ?       S    11:35   1:04 /usr/sbin/apache2 -k start
    www-data  5740  0.4  6.4 442128 113164 ?       S    11:53   1:03 /usr/sbin/apache2 -k start
    www-data  5741  0.4  6.3 441360 111712 ?       S    11:53   0:56 /usr/sbin/apache2 -k start
    www-data  5748  0.4  6.3 441152 111352 ?       S    11:54   1:03 /usr/sbin/apache2 -k start
    www-data  7171  0.5  6.1 438680 108500 ?       S    13:15   0:44 /usr/sbin/apache2 -k start
    www-data  7176  0.4  6.0 434788 106156 ?       S    13:15   0:39 /usr/sbin/apache2 -k start
    www-data  7180  0.4  4.8 412348 84276 ?        S    13:15   0:40 /usr/sbin/apache2 -k start
    www-data  7183  0.4  6.0 436404 105884 ?       S    13:15   0:42 /usr/sbin/apache2 -k start
    www-data  7449  0.4  6.0 436816 105672 ?       S    13:30   0:35 /usr/sbin/apache2 -k start
    www-data  7584  0.4  6.1 438848 108184 ?       S    13:38   0:29 /usr/sbin/apache2 -k start
    www-data  7586  0.4  5.4 426096 95776 ?        S    13:38   0:34 /usr/sbin/apache2 -k start
    www-data  7589  0.5  6.1 438784 108500 ?       S    13:38   0:37 /usr/sbin/apache2 -k start
    www-data  7612  0.5  6.2 438840 110072 ?       S    13:39   0:42 /usr/sbin/apache2 -k start
    www-data  7815  0.5  6.1 438524 108296 ?       S    13:52   0:34 /usr/sbin/apache2 -k start
    www-data  7818  0.4  6.5 444132 115312 ?       S    13:52   0:30 /usr/sbin/apache2 -k start
    www-data  8565  0.3  6.0 436516 106940 ?       S    14:29   0:15 /usr/sbin/apache2 -k start
    www-data  8612  0.4  5.7 430564 100064 ?       S    14:31   0:20 /usr/sbin/apache2 -k start
    www-data  8613  0.4  5.2 421100 91464 ?        S    14:31   0:19 /usr/sbin/apache2 -k start
    www-data  8615  0.4  6.2 437816 108756 ?       S    14:31   0:18 /usr/sbin/apache2 -k start
    www-data  8616  0.4  6.2 441132 110080 ?       S    14:31   0:18 /usr/sbin/apache2 -k start
    www-data  8617  0.4  6.0 434720 105772 ?       S    14:31   0:18 /usr/sbin/apache2 -k start
    www-data  8618  0.4  4.7 412620 83376 ?        S    14:31   0:20 /usr/sbin/apache2 -k start
    www-data  8632  0.4  6.3 440428 111280 ?       S    14:34   0:16 /usr/sbin/apache2 -k start
    www-data  8675  0.5  6.3 440176 110512 ?       S    14:35   0:21 /usr/sbin/apache2 -k start
    www-data  8679  0.4  6.1 436796 107532 ?       S    14:36   0:15 /usr/sbin/apache2 -k start
    www-data  8861  0.5  6.0 436936 106152 ?       S    14:50   0:16 /usr/sbin/apache2 -k start
    www-data  8862  0.5  6.2 439588 110364 ?       S    14:50   0:17 /usr/sbin/apache2 -k start
    www-data  8863  0.3  5.8 432308 102788 ?       S    14:50   0:11 /usr/sbin/apache2 -k start
    www-data  8937  0.4  6.4 440856 112348 ?       S    14:59   0:12 /usr/sbin/apache2 -k start
    www-data  9342  0.4  4.6 411788 81516 ?        S    15:33   0:01 /usr/sbin/apache2 -k start
    www-data  9408  0.5  4.8 414664 84512 ?        S    15:39   0:00 /usr/sbin/apache2 -k start

vmstat 15 5 output:

    procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
     r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
     0  0  97296  70168  25660 142736    4    6    79    69  132  177 15  1 82  2
     0  0  97292  70136  25684 142792    0    0     5    51   78  102 10  0 89  1
     0  0  97292  71964  25700 143124    0    0    21    53  113  163 15  0 82  2
     1  0  97292  69020  25728 143872    6    0    57    49   86  123 10  0 87  2
     0  0  97284  62704  25756 144668    4    0    53    78  163  191 22  2 76  1

Apache is running in prefork mode, this is my configuration:

    <IfModule mpm_prefork_module>
    StartServers 5
    MinSpareServers 15
    MaxSpareServers 35
    MaxClients          150
    MaxRequestsPerChild 4000
    </IfModule>

When this machine starts locking up, it goes bad really quick, and usually forces me to powercycle it, which isn't all that healthy for the system, so hopefully someone here has some good ideas. Thanks!

share|improve this question
    
Anything in the Apache error logs when it dies? –  Shane Madden Oct 24 '11 at 19:57
1  
It doesn't have much memory to go on, so you're probably right about your hunch. My guess is that it starts to swap, and things go bad from there. Make sure that your webapp is unable to starve the servers resources. –  Kvisle Oct 24 '11 at 20:04
    
The numbers do suggest that memory is the issue. The next question is why. You might try turning down 'MaxRequestsPerChild' in case it's a leak. (Does the Apache2 VSZ go up gradually over time? Is it always about the same when the machine gets unresponsive? It's 410-450MB in your ps output.) –  David Schwartz Oct 25 '11 at 4:52

1 Answer 1

There's a few warning flags here for me.

1) VPS server. Not known for their performance, and well known for limited RAM.

2) Apache2. Probably a stock install, and not tuned for VPS operation.

In your /etc/apache2/apache2.conf, locate the line that says something like: Keepalive On and change it to Keepalive Off

This frequently improves Apache performance on a VPS server.

Other things you might want to check:

  • Have you set up a robots.txt file to stop you getting hammered by search crawlers?
  • Assuming you're running PHP, are you using APC or something similar as an opcode cache? This will massively cut down how much memory Apache needs.
share|improve this answer
    
Thanks for your response. I turned KeepAlive off, and will see what happens. I am using eAccelerator, which seems to be behind in development, but is the most popular choice from what I can tell. As for the robots.txt suggestion, I really don't want to block search engines, unless you have something specific in mind. Thanks again! –  se_dude Oct 25 '11 at 17:04

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.