This may not be the best forum for this topic, if so, I apologize in advance.

We have a server that several sites are hosted on. Recently we launched our first Drupal site on this server and have had the server run out of memory several times. Here are some details:

* The server has 2GB of RAM in it.
* PHPs memory_limit is set to 96MB in .htaccess for this site
* This site has it's cron run every hour
* We have a cron hook that makes SOAP calls to a 3rd party. This hook takes about 5 minutes to run

The thing that's odd is that each Apache instance, including idle instances, seems to eat up about 100MB. I assume this is due to the 96MB PHP memory_limit, but I am not sure. I understood that Apache would not allocate that RAM until PHP requests it.

At the time the server dies, it appears that server load is not very high, and that MySQL isn't using much CPU or RAM. It seems that the Drupal cron is running, but it's only taking about 25% of CPU.

Obviously, the server dying due to "out of memory" errors is an issue. I am not sure how to adjust Drupal in a way that it will be more conservative with memory and still perform it's function. As such, I'm skeptical of doing something like reducing memory_limit to 64MB; doing so would just cause white PHP error pages.

Please let me know if I can provide any additional information for troubleshooting purposes.

Comments

kbahey’s picture

Memory under Linux is not freed back to the operating system immediately. So if a process uses memory and then frees it, it is still marked as in use. The only sure way to free memory is to terminate the process.

For Apache, this can be done by adjusting the MaxRequestsPerChild to a lower value, so the process dies sooner rather than later.

Another thing to do is adjust the MaxClients so that the total number of Apache processes is not too large to fit in real memory and cause the server to swap.

Yet another thing to do is install APC or eAccelerator. It will save the amount of memory used per process because each script will be pre-"compiled" and does not have to be reloaded for every page request.
--
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

seanray’s picture

You can increase PHPs memory_limit to see it's still there or not.

Kaumil’s picture

My recommendation is to increase your ram or find a solution that can scale with your websites demands without capping out at these hard limits.

Clustered Drupal Hosting powered by Uptimehost's Cloud.

kts4’s picture

jwalkercbi,

I'm having the similar problem as you. I am running a server with 2GB RAM and have a PHP memory_limit of 128MB. I am not running cron, but am still running out of free memory. The server load is very low (usually < 0.2), yet the free memory sometimes runs out causing blank pages.

I have installed the Boost module in hopes of decreasing memory usage, but have not seen better usage.

Did you find a solution to your memory issue?

vodoleq’s picture

I'm having the similar problem

vlooivlerke’s picture

My sites used to work fine, now suddenly it started using allot of memory to process simple things.

sreyas’s picture

This issue has been happening for one of my client and had crashing almost every 3 hours causing memory +swap to run out of space.

Since the php process were taking too much memory around 60-90 mb per process only option was to decrease the maxclients option and set the optimized maxrequestperchild value so that its suits the best for this server. Please note if you are shared hosting you dont have control over this and probably would get suspended for high memory usage. But if you dedicated server try decreasing these values and check how it goes.

Regards
sreyas

------------------
Ciril Sreedhar
Sreyas IT Solutions
Server Administration | Web Designing | Web Programming

prokopton’s picture

I use a VPS and followed the instructions here: http://library.linode.com/troubleshooting/memory-networking#diagnosing_a...

We'll see how it goes.

Here were my error messages: (has something to do with anon-rss and file-rss)

"RSS" stands for "resident set size," one way to measure the amount of memory used by a process in Linux. It does not refer to RSS feeds.

Killed process 18762 (apache2) vsz:187372kB, anon-rss:20172kB, file-rss:380kB
Out of memory: kill process 18740 (apache2) score 46907 or a child
Killed process 18740 (apache2) vsz:187628kB, anon-rss:19900kB, file-rss:576kB
Out of memory: kill process 18739 (apache2) score 46974 or a child
Killed process 18739 (apache2) vsz:187896kB, anon-rss:20400kB, file-rss:0kB
Out of memory: kill process 18723 (apache2) score 47043 or a child
Killed process 18723 (apache2) vsz:188172kB, anon-rss:20680kB, file-rss:660kB
Out of memory: kill process 18735 (apache2) score 47239 or a child
Killed process 18735 (apache2) vsz:188956kB, anon-rss:22036kB, file-rss:420kB
Out of memory: kill process 18758 (apache2) score 47239 or a child
Killed process 18758 (apache2) vsz:188956kB, anon-rss:20692kB, file-rss:400kB
Out of memory: kill process 18732 (apache2) score 47435 or a child
Killed process 18732 (apache2) vsz:189740kB, anon-rss:22000kB, file-rss:420kB
Out of memory: kill process 18745 (apache2) score 47569 or a child
Killed process 18745 (apache2) vsz:190276kB, anon-rss:23052kB, file-rss:508kB
Out of memory: kill process 18809 (apache2) score 47635 or a child
Killed process 18809 (apache2) vsz:190540kB, anon-rss:21476kB, file-rss:624kB
Out of memory: kill process 18784 (apache2) score 47633 or a child
Killed process 18784 (apache2) vsz:190532kB, anon-rss:21748kB, file-rss:624kB
Out of memory: kill process 18760 (apache2) score 47770 or a child
Killed process 18760 (apache2) vsz:191080kB, anon-rss:22212kB, file-rss:412kB
Out of memory: kill process 18786 (apache2) score 47770 or a child
Killed process 18786 (apache2) vsz:191080kB, anon-rss:23148kB, file-rss:308kB
Out of memory: kill process 18747 (apache2) score 47966 or a child
Killed process 18747 (apache2) vsz:191864kB, anon-rss:23864kB, file-rss:352kB
Out of memory: kill process 18748 (apache2) score 47966 or a child
Killed process 18748 (apache2) vsz:191864kB, anon-rss:24024kB, file-rss:320kB
Out of memory: kill process 18746 (apache2) score 47966 or a child
Killed process 18746 (apache2) vsz:191864kB, anon-rss:23296kB, file-rss:380kB
Out of memory: kill process 18767 (apache2) score 48100 or a child
Killed process 18767 (apache2) vsz:192400kB, anon-rss:25076kB, file-rss:612kB