Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a way to limit the number of children than mysqld spawns? Or should one not worry about that? My VPS only has 512MB of RAM.

Here's the output of htop, after I set max_connections to 6 and restarted the mysql service:

  PID USER     PRI  NI  VIRT   RES   SHR S CPU% MEM%   TIME+  Command
27082 mysql     20   0  136M 28868  5800 S  0.0  5.7  0:00.41  `- /usr/sbin/mysqld
27121 mysql     20   0  136M 28868  5800 S  0.0  5.7  0:00.05  |   `- /usr/sbin/mysqld
27099 mysql     20   0  136M 28868  5800 S  0.0  5.7  0:00.23  |   `- /usr/sbin/mysqld
27097 mysql     20   0  136M 28868  5800 S  0.0  5.7  0:00.00  |   `- /usr/sbin/mysqld
27096 mysql     20   0  136M 28868  5800 S  0.0  5.7  0:00.00  |   `- /usr/sbin/mysqld
27095 mysql     20   0  136M 28868  5800 S  0.0  5.7  0:00.00  |   `- /usr/sbin/mysqld
27094 mysql     20   0  136M 28868  5800 S  0.0  5.7  0:00.02  |   `- /usr/sbin/mysqld
27093 mysql     20   0  136M 28868  5800 S  0.0  5.7  0:00.01  |   `- /usr/sbin/mysqld
27091 mysql     20   0  136M 28868  5800 S  0.0  5.7  0:00.00  |   `- /usr/sbin/mysqld
27090 mysql     20   0  136M 28868  5800 S  0.0  5.7  0:00.00  |   `- /usr/sbin/mysqld
27089 mysql     20   0  136M 28868  5800 S  0.0  5.7  0:00.00  |   `- /usr/sbin/mysqld
27088 mysql     20   0  136M 28868  5800 S  0.0  5.7  0:00.00  |   `- /usr/sbin/mysqld

I've installed MySQL using aptitude.

$ aptitude search '~i'
i A mysql-client-5.1                                                                - MySQL database client binaries
i A mysql-client-core-5.1                                                           - MySQL database core client binaries
i A mysql-common                                                                    - MySQL database common files, e.g. /etc/mysql/my.cnf
i   mysql-server                                                                    - MySQL database server (metapackage depending on the latest version)
i A mysql-server-5.1                                                                - MySQL database server binaries and system database setup
i A mysql-server-core-5.1                                                           - MySQL database server binaries
share|improve this question
add comment

2 Answers

you could use max_user_connections to limit the number of connections that a single mysql user can have at one time

http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_max_user_connections

you'd need to try a few different settings / combinations of max_connections and max_user_connections to get the best performance without running out of connections.

also, its not a 1:1 ratio between connections and threads.

http://dev.mysql.com/doc/internals/en/threads.html

share|improve this answer
add comment

I don't know exactly what those child processes are, but I believe that they are nothing to worry about.

Your htop reading shows that /usr/sbin/mysqld is using 136 MB of RAM total (from the VIRT field). The child processes are not using any more noticeable amount of RAM. 136 MB may seem like a lot, but MySQL is naturally demanding for memory.

If you think that CPU usage is a concern, it shouldn't be. The TIME+ field shows little usage of any of the mysqld processes.

I once had a VPS with 512 MB of RAM, too. It was my poor choice of software that led me to running out of RAM—I tried running multiple virtual servers with Virtualmin. 512 MB isn't much, and virtualization solutions like OpenVZ don't let you swap anything out to disk, so watch out for other factors that could increase your RAM usage.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.