[TAG] Optimizing Apache2 and MySQL install

Thomas Adam thomas at edulinux.homeunix.org
Wed Jun 22 06:09:54 MSD 2005


On Tue, Jun 21, 2005 at 09:58:24PM -0400, Suramya Tomar wrote:
> Is there some way I can optimize MySQL and Apache and tell it not to
> use so much RAM/CPU? I tried searching on the web but didn't find

Well, there is.  If it is _really_ a problem, you could compile your own
kernel, and not compiling the OOM-killer into it.  That would stop the
kernel's divine intervention, at any rate.

More practical purposes though would be to limit the amount of RAM that
the processes can use.  Recent versions of PAM allow for this through
the file:  /etc/security/limits.conf  For example, on Debian, Apache
runs via the user 'www-data'.  In that file, you could add an entry
thus:

``
www-data  soft     cpu       6000
www-data  hard     memlock   700000
''

The difference between hard and soft is almost analogous to how quota
enforces them -- soft is a graceful enforce, while hard is a complete
cut-off.  The values above are examples only -- you should change them
to suit your needs, at any rate.

The use of limits.conf via PAM is really much more applicable to
daemon-based tools, although it can be applicable to anything.  It used
to be the case that you'd have to do:

``
ulimit -l <some_value>
''

.. and you still can.  It's great to do that for login shells, etc.  The
problem with that is for daemon processes that do not spawn a shell when
the process starts, makes it invalid.  Not to mention the user that the
daemon runs at doesn't have a shell.

You can apply a similar methodology for MySQL.

-- Thomas Adam

--  
"One of us is a cigar stand, and one of us is a lovely blue incandescent
guillotine" -- Stephen Malkmus, "Type Slowly" from "Brighten The Corners"





More information about the TAG mailing list