I just got a VPS plan but my site is not open to the public yet. I am the only one using it but I runs out of memory all the time when browsing the site and testing to make sure the links work fine. I had to increase my memory from 96MB to 128MB but no luck. This is my memory usage from the free -m command

total used free shared buffers cached
Mem: 128 125 3 0 26 18
-/+ buffers/cache: 80 48
Swap: 63 13 50

From the ps -aux, I notice that 2 apache services are using almost 50% of my memory. What can I do about this?

apache 30050 0.0 25.1 57556 33008 ? S Jan15 0:51 /usr/sbin/httpd
apache 30053 0.0 24.3 56480 31936 ? S Jan15 0:54 /usr/sbin/httpd

Comments

scottm316’s picture

Check the apache config. Usually if your php_memory_limit is higher you need to adjust the MaxClients setting. If you have a high php memory limit but still the default setting for MaxClients - this can happen. A safe rule of thumb is:

MaxClients = Total RAM / average apache process size

Unless you have crazy modules doing crazy stuff there isn't much need for more than 96. Even that is lots, and I know Imagecache complains unless you have it. But if not everyone is uploading and resizing images via imagecache you can turn it down. If only the administrator uses imagecache, then no big deal its just going to take an extra second or two to upload and process the images.

You can also implement caching in MySql. Specifically query caching since it is not on by default.

Sincerely,

Scott Morrison
Scott eSolutions Ltd.
www.scottesolutions.com
Edmonton, AB

Scott
http://morrisonmultimedia.ca/
Edmonton, AB

tanyi’s picture

My php_memory_limit is set to 32MB. It was set to 16MB but my host increased it to 16MB because it ran out of memory.

Also I have installed imagecache, enabled then disabled it because I do not need it. Do I need to delete the imagecache folder and directory or is disabling it ok?

tanyi’s picture

I checked my apache config and I have two MaxClients setting

# MaxClients: maximum number of server processes allowed to start
MaxClients 20

and

# MaxClients: maximum number of simultaneous client connections
MaxClients 150

which of these should I change?

scottm316’s picture

Sorry for the delay, I thought I signed up for notifications when someone responds but apparantly that's not happening. The second one. Those two MaxClient references are used under different circumstances(namely if prefork.c and if worker.c). Adjust the setting in line with the formula above, and keep experimenting until you find a good balance.

As long as the module is disabled it won't chew up any memory unnecessarily.

Sincerely,

Scott Morrison
Scott eSolutions Ltd.
www.scottesolutions.com
Edmonton, AB

Scott
http://morrisonmultimedia.ca/
Edmonton, AB

seanray’s picture

Another suggestion is to increase your vps memory. 256MB should be a good one for Drupal.

kbahey’s picture

There are several possibilities:

1. You are using too many Drupal modules, and they eat up memory in PHP.

2. Apache has a lot of unused modules (that is apache modules, not Drupal modules). Do apache -t -D DUMP_MODULES to find out what modules you have and disable the ones you don't need. You basically need mod_php, mod_rewrite, mod_deflate and little else. Disable cgi ...etc.

3. Install eAccelerator or APC, which will save memory if #1 is the case.

4. Site may be too complex, with lots of blocks, views, CCK, ...etc.

You can also investigate FastCGI or fcgid, which can save memory.

Having said all that, 128MB is a bit tight regardless. 256MB is a more sane option.
--
Drupal performance tuning, development, customization and consulting: 2bits.com, Inc.
Personal blog: Baheyeldin.com.

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

Diegen’s picture

I have a similar problem, I have 17 reseller accounts at Lunarpages. Of the 17 accounts most of them are wordpress sites. I checked out VPS and it is a bit cheaper in the long run ( I can add more accounts without paying ) so I am thinking of migrating all 17 accounts to a VPS. The VPS solution they offer has 512MB Memory, 20GB Disk Spaceand 1000 GB Bandwidth.

Is this enough resources or should I look into something else ? I am getting into drupal and will be building some drupal sites in the short future. I want to go dedicated but at $99 for a celeron with less ram I am a bit worried that it would be even more of a risk.

Diegen’s picture

I switched to Media Temple, and I am happy I did. Sofar so good.

wwwoliondorcom’s picture

Huge memory usage on Dreamhost VPS, how to find which module causes troubles ?

Hi,

I have the same problem, how can i find what is the module that uses too much memory on my dreamhost virtual private server ?

Website has a lot of traffic but no more than before and suddenly thousands of errors everyday when i haven't changed a single module, so what's wrong ?

Thanks.

ptoly’s picture

I've been having no end of problems on Dreamhost. Sites which have small traffic and few modules keep hitting memory limits. I've moved servers and still have problems.

I'm fairly sure the main problem, based on my experience working on a huge Drupal installation, is that the pipe between the Apache machine and the MySQL machine and/or the MySQL setup itself, is not optimized.

Drupal is a huge demander of queries and, often forgotten, is that takes a hit on the database server. Lately I've been getting a lot of Gateway timeouts on Dreamhost Drupal setups and I'm hazarding a guess it is the communication between the two servers that is the problem.

None of the shared/cheap hosting I've looked into bother much with that, instead focusing on php, apache, and memory. They do a lot to fine tune how the web server is shared, but I'm not clear if they do much about the MySQL server, which, if it is really busy, will be slowed.

Good luck!

gr33nman’s picture

I'm on a Dreamhost VPS with 633MB RAM. Most of the time, we're using way below 100mb. occasionally, when traffic gets more heavy, we'll use just a bit above 100MB. Load is rarely above 0.25. Unfortunately, we keep gettings spikes at just above 633MB RAM. Load only goes up to almost .5 when that happens.

I think it might be a cron thing, because it's happening consistently at 2:16am or 6:12am every other day or so. I know it sounds like lot of modules, but it's really not, is it?

Including core modules, there are 114 on the main live and dev sites, and around 90 per site for each of the other sites.

I'm tired of getting emails saying my VPS has rebooted at 2:18 or 6:18 every other day, and I'd really rather bring my VPS down to a more manageable 300MB RAM if I can work this out.

Any help would be greatly appreciated.