What's your Max_connections?

What's your Max_connections?

by way car -
Number of replies: 4

Hi Friends,

The default value is 100. When  more than 100 people access moodle, there will be database overloaded warning ( Is it right? ).   Can I change this parameter into 1000 or more?  What's your Max_connections?

I am looking  forward to your reply. Thanks a lot.

Average of ratings: -
In reply to way car

Re: What's your Max_connections?

by Ken Wilson -
Be careful about increasing the default value as this will have an impact on the per connection memory usage. For each connection made by a client to the MySQL server, buffer memory is allocated according to this formula (I've put similar buffers together and these are the important ones):

Per connection memory usage = thread_stack +
net_buffer_length + max_allowed_packet +
read_buffer_size + read_rnd_buffer_size +
sort_buffer_size + myisam_sort_buffer_size +
join_buffer_size +
bulk_insert_buffer_size


So this gives

Total connection memory usage = Per connection memory usage * max_connections

Notice the multiplying factor - if you increase max_connections you'll get a multiplying of the memory usage. It's best practice to make sure that you don't allow the server to exceed it's free RAM, otherwise it'll start swapping memory to disk and things will slow down considerably.

By all means increase the value of max_connections - but remember that connections last for milliseconds, so only do it when you're expecting a peak in usage and know that the maximum value that you can increase it to depends on the free RAM in your server.

Hope this helps!

Ken
In reply to Ken Wilson

回复: Re: What's your Max_connections?

by way car -

Thank you so much for your detailed reply and reminding.

My server's RAM has been upgraded to 4G. So I suppose it's enough to change the Max_connections into 200 at least.

The reason for this changing is that there are more than 100 people log on my Linux+apache+mysql+php system simultaneously and edit their courses.  They often meet the error: database connection failed.

But I worry about slowing down or even collapsing because of the excessive memory consumption. So I have not taken acton yet.