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 this VPS with 512MB RAM and I think apache2 is killing it! I can't load pages from the server (using my browser), access FTP or SSH. The VPS really stop responding. I'm only running apache2, php and MySQL on it, the machine is only being used to host a single wordpress blog.

top shows the following:

top - 03:17:59 up 22:31,  1 user,  load average: 60.54, 44.38, 23.35
Mem:    498320k total,   420888k used,    77432k free,      388k buffers
Swap:  2096124k total,  2094196k used,     1928k free,    14068k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
18312 www-data  20   0  171m  15m  828 D    0  3.1   0:00.44 apache2
18305 www-data  20   0  170m  13m  992 D    0  2.8   0:00.48 apache2
18273 www-data  20   0  170m  13m 1008 R    0  2.8   0:00.41 apache2
18314 www-data  20   0  171m  13m  784 D    0  2.7   0:00.38 apache2
18307 www-data  20   0  171m  12m  668 D    0  2.6   0:00.40 apache2
18267 www-data  20   0  177m  11m  892 D    0  2.3   0:01.23 apache2
18248 www-data  20   0  177m  10m  872 D    0  2.2   0:02.29 apache2
17955 www-data  20   0  213m  10m  796 D    3  2.1   0:04.76 apache2
18053 www-data  20   0  216m 9964  812 D    0  2.0   0:02.48 apache2
18288 www-data  20   0  173m 9828  572 D    0  2.0   0:01.22 apache2
18237 www-data  20   0  177m 9256  936 D    0  1.9   0:02.13 apache2
18174 www-data  20   0  199m 8784  932 D    0  1.8   0:01.68 apache2
18167 www-data  20   0  199m 8656  904 D    0  1.7   0:02.58 apache2
18183 www-data  20   0  187m 7992  784 D    1  1.6   0:00.97 apache2
18309 www-data  20   0  177m 7876  860 D    0  1.6   0:00.58 apache2
17688 www-data  20   0  217m 7820   24 D    0  1.6   0:08.12 apache2
18170 www-data  20   0  157m 7688  892 D    0  1.5   0:00.40 apache2
18239 www-data  20   0  175m 7684  656 S    0  1.5   0:00.64 apache2
18060 www-data  20   0  195m 7528  920 D    0  1.5   0:01.17 apache2
18204 www-data  20   0  182m 7240 1048 D    1  1.5   0:00.87 apache2
18245 www-data  20   0  175m 7192  644 S    0  1.4   0:00.62 apache2
18232 www-data  20   0  175m 7076  540 D    0  1.4   0:02.52 apache2
18240 www-data  20   0  177m 7028  912 D    1  1.4   0:02.10 apache2
18168 www-data  20   0  180m 6848  960 D    0  1.4   0:01.71 apache2
18306 www-data  20   0  177m 6688  628 D    0  1.3   0:01.89 apache2
18244 www-data  20   0  171m 6588  480 D    0  1.3   0:00.58 apache2
18250 www-data  20   0  177m 5884  896 D    1  1.2   0:03.02 apache2
18176 www-data  20   0  201m 5848  848 D    0  1.2   0:01.22 apache2
18246 www-data  20   0  175m 5400  832 D    0  1.1   0:00.67 apache2
18178 www-data  20   0  201m 5080  860 D    0  1.0   0:02.51 apache2
18365 www-data  20   0  153m 5028  976 D    1  1.0   0:00.10 apache2
18313 www-data  20   0  153m 4944  980 D    1  1.0   0:00.17 apache2
17796 www-data  20   0  218m 4724  808 D    0  0.9   0:05.02 apache2
17681 www-data  20   0  218m 4448  452 D    1  0.9   0:06.90 apache2
17692 www-data  20   0  223m 4228  856 D    0  0.8   0:08.23 apache2
17690 www-data  20   0  217m 4052  656 D    0  0.8   0:09.07 apache2
17680 www-data  20   0  223m 3976   68 D    0  0.8   0:04.86 apache2
17789 www-data  20   0  213m 3852  636 D    0  0.8   0:07.20 apache2
17899 www-data  20   0  225m 3852  588 S    0  0.8   0:02.89 apache2
17676 www-data  20   0  218m 3812  400 D    1  0.8   0:11.65 apache2
17685 www-data  20   0  218m 3760  604 D    0  0.8   0:07.79 apache2
17963 www-data  20   0  226m 3456  424 S    0  0.7   0:04.27 apache2
17946 www-data  20   0  226m 3452   72 D    0  0.7   0:08.25 apache2
18363 www-data  20   0  151m 3376  812 D    0  0.7   0:00.06 apache2
17953 www-data  20   0  224m 3244   76 D    0  0.7   0:05.16 apache2
17764 www-data  20   0  218m 3152   12 D    0  0.6   0:11.63 apache2
18251 www-data  20   0  152m 3036  720 D    0  0.6   0:00.44 apache2
18003 www-data  20   0  216m 2856   20 D    0  0.6   0:05.80 apache2
18368 www-data  20   0  151m 2812  788 D    0  0.6   0:00.06 apache2
18013 www-data  20   0  216m 2808   24 D    0  0.6   0:03.16 apache2
18283 www-data  20   0  152m 2744  860 D    0  0.6   0:00.24 apache2
17794 www-data  20   0  216m 2696   28 D    0  0.5   0:06.49 apache2

apache2.conf: http://pastebin.com/nGtAR4Dk /etc/php5/apache2/php.ini: http://pastebin.com/mjPSbH0t

What do I need to change to make apache2 use less resource from this machine?

Thanks.

share|improve this question
add comment

1 Answer 1

Drop MaxClients to something much, MUCH lower than 150 to start with. Based on the size of your Apache processes, I'd be starting with something like 10 or 20. That'll at least stop the thing from dying on a regular basis.

Then you can start looking at reducing the memory footprint of those processes, by removing PHP and Apache modules you don't need. Given your memory constraints and apparent load, I'd say you'll almost certainly see a big benefit from switching to the worker MPM and an external PHP runner, or (if you're feeling really adventurous) dumping Apache altogether and using nginx. The benefits of this vary based on your ratio of static files served, but I've always thought the "every Apache process needs a copy of PHP running" model to be fairly fatally flawed.

share|improve this answer
    
All the MaxClients parameters or one in particular? I`ve tried nginx and kinda had the same problem. Looks like the default config for every server don`t work for me. With nginx, php-fpm was the problem. Had too much php-fpm processes on the server. Does that mean that PHP is my problem with this high server load? –  Marcio Matielo Aug 12 '11 at 2:30
    
So run fewer php-fpm processes -- or, if they can't keep up with the load, get a bigger server. –  womble Aug 12 '11 at 3:05
    
I managed to keep the server running without crashing the server. But check this out. Used a script to show me the page generation time and got this: Page generated in 41,00000 seconds ( 99,80% PHP, 0,20% MySQL ). If I use the default id=xyz permalink, pages are loaded in 1 second or less. If I use the %postname% permalink tipe, page takes more then 40 seconds to generate. –  Marcio Matielo Aug 12 '11 at 3:42
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.