var sidebar_align = 'right';
var content_container_margin = parseInt('350px');
var sidebar_width = parseInt('330px');
MySQL and Apache, number of connections
Is there a rule of thumb in setting the number of apache & MySQL connections, sorta like a ratio ? My forum has about 60-80 members online with a multimedia section containing big files.
I've set both to 1,000 on a P4 with 1GB of ram, Linux CentOS 3.4. Is that harmful? Any advice is appreciated.
I'd set the limit to be 2.5x your normal high....or you risk meltdown if Apache gets bombed with requests.
Same goes for MySQL, but just keep the number of MySQL connetions above Apache's limit, or users will get connection errors.
This is usually best found out with experience of the machine you are running because there are soo many factors involved. If you set it too high, apache and/or mysql will crash often.
How could I check/change the number of connections for MySQL and Apache? and do I need to reboot the services for it to take effect?
You can limit the number of connections for MySql by changing the number of connections in /etc/my.conf file. The following is the code that you need to have:-
Please note that it is not necessary that the figures should be the same as it is above.
set-variable = max_connections=800
set-variable = connect_timeout=8
set-variable = read_buffer_size=2M
set-variable = sort_buffer=2M
set-variable = key_buffer_size=16M
set-variable = max_allowed_packet=2M
You can refer to the following link for more details:-
Apache connections can be limited with the help of the following command:-
Syntax: KeepAlive max-requests
Ex: KeepAlive 5
ps -ef | grep httpd | wc -l
Will show you the number of apache threads currently running. You can also monitor this with a handy performance graphing tool like hotsanic.
For mysql, it depends on how you have it compiled. If you have it with linuxthreads, you can use:
ps -ef | grep mysqld | wc -l
Or use apachetop and/or mysqltop.
Edit MaxClients in httpd.conf for apache
/etc/my.cnf max_connections for mysql.
You need to restart the services for this to take effect..