Results 1 to 6 of 6

Thread: Many MySQL, Apache und named processes eat all the RAM

  1. #1
    Join Date
    Jun 2013
    Beans
    3

    Many MySQL, Apache und named processes eat all the RAM

    Hi all.

    I run a VPS on Ubuntu Server 10.04. The server has something about 750 Mb RAM, which is, soon after the server has started, almostly all consumed by numerous mysqld, named and apache2 processes:

    https://dl.dropboxusercontent.com/u/...2013.54.38.png

    There are 2-4 websites with very little traffic running on this server.

    Can I somehow optimise this or I simply need more RAM? I think there is something wrong, that a server without any serious workload consumes so much memory.

  2. #2
    Join Date
    Nov 2008
    Location
    Storybrooke
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Many MySQL, Apache und named processes eat all the RAM

    Quote Originally Posted by rreimche View Post
    Hi all.

    I run a VPS on Ubuntu Server 10.04. The server has something about 750 Mb RAM, which is, soon after the server has started, almostly all consumed by numerous mysqld, named and apache2 processes:

    https://dl.dropboxusercontent.com/u/...2013.54.38.png

    There are 2-4 websites with very little traffic running on this server.

    Can I somehow optimise this or I simply need more RAM? I think there is something wrong, that a server without any serious workload consumes so much memory.
    I see the top memory users are apache/mysql

    First, Apache is kind of a memory hog, if you want it to fit on a small VPS, use something like nginx + php5-fpm which is much much much much lighter, and will have a greater chance on fitting on 750 Mb RAM.

    Second, MySQL is kind of heavy too, if you have little traffic, you may want to limit the amount of mysql processes that are spawned.
    See http://superuser.com/questions/34559...t-mysql-spawns and http://stackoverflow.com/questions/6...ses-or-threads

    You can set those options by adding them to /etc/mysql/my.cnf , and restarting mysql

    Also, if your not using bind9 (dns server), it is sometimes installed on VPS templates by default
    If you dont need it, remove it by running
    Code:
    sudo apt-get remove bind9
    Last edited by sandyd; June 30th, 2013 at 12:00 PM.
    Ubuntu Forums Moderation Staff
    Don't waste your energy trying to change opinions ... Do your thing, and don't care if they like it.

  3. #3
    Join Date
    Jun 2013
    Beans
    3

    Re: Many MySQL, Apache und named processes eat all the RAM

    Thank you, sandyd.

    Could you tell me, please, if I don't use any CGI stuff, could I stay without php5-fpm?

  4. #4
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    9,976
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: Many MySQL, Apache und named processes eat all the RAM

    You can reduce Apache's footprint to some degree by limiting the number "children" it spawns. In /etc/apache2/apache2.conf take a look at:

    Code:
    IfModule mpm_prefork_module>
        StartServers          5
        MinSpareServers       5
        MaxSpareServers      10
        MaxClients          150
        MaxRequestsPerChild   0
    </IfModule>
    Try starting with 3 for the first two items and 5 for MaxSpareServers.

    That said, I have apache, mysql, postgresql, bind9, and a couple of other items running on a 512 MB CentOS 6 virtual server and have memory left to spare.

    Code:
    Mem:    506644k total,   437972k used,    68672k free,    67608k buffers
    Swap:   262140k total,    73744k used,   188396k free,    62072k cached
    Do you have a swap partition? That can help some, though as you see here only about 70M is in use. If you don't have and cannot configure a partition for swap, create a swapfile on the drive and use that instead.

    However I'll also mention that I did not follow my own advice about the number of children and still do not have a memory problem. This machine currently has 20 apache child processes running, each of them using somewhere between 10MB and 20MB of unique memory. (About 30 MB is shared by all the children.)

    My mysqld runs with just a single process consuming about 125MB. PostgreSQL starts five processes which collectively add up to about the same amount of memory as mysqld.

    It's possible that one of the web applications you are running is misconfigured somehow and spawning unending processes. I've had that experience with PG and large databases. If the database is not well-indexed, people running a SELECT query can grow tired of waiting for the results and try to cancel the request by hitting stop in the browser or reloading the page. The background SQL process will not die in this case, but just hang idle in the background. Reloading is even worse since an entirely new process will be spawned as well.
    If you ask for help, please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  5. #5
    Join Date
    Nov 2008
    Location
    Storybrooke
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Many MySQL, Apache und named processes eat all the RAM

    Quote Originally Posted by rreimche View Post
    Thank you, sandyd.

    Could you tell me, please, if I don't use any CGI stuff, could I stay without php5-fpm?
    If you don't need PHP5, you don't need php5-fpm.
    Ubuntu Forums Moderation Staff
    Don't waste your energy trying to change opinions ... Do your thing, and don't care if they like it.

  6. #6
    Join Date
    Jun 2013
    Beans
    3

    Re: Many MySQL, Apache und named processes eat all the RAM

    Thanks. Very useful.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •