[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Limiting Memory Use Per Process/User



Marcin Owsiany wrote:
> On Tue, May 03, 2005 at 11:44:13PM -0700, Stephen Le wrote:
> 
>>I was wondering if there was a way to limit the amount of memory used
>>by any single process or user. I'd like to prevent Apache (and other
>>server daemons) from consuming all available memory and thrashing my
>>disk when everything else is forced to swap.
> 
> 
> Note that resource limits (ulimit etc) won't prevent that. Instead, they
> will just cause apache to abort with an "out of memory" error. There
> would have to be a resource limiting mechanism internal to apache, and
> PHP, in this case, to provide such thing. I don't believe there are
> such, though. FWIW, java has something closest to this, as you can
> fine-tune the garbage collector and heap sizes, at least in Sun's
> implementation.

You might want to check D.J. Bernstein's daemontools
(http://cr.yp.to/daemontools.html). As far as I know it is possible to
limit memory usage with one of the tools. It will abort Apache with a
"out of memory" error though. And then start it up again.

Another way would be to use monit (http://www.tildeslash.com/monit/).
You can monitor resources (CPU, memory, ...) and eventually trigger some
action with it.


Michael



Reply to: