Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximum concurrent connections to MySQL

Tags:

database

mysql

I want to set up a MySQL database for a social networking website for my college.

My app can have at most 10,000 users. What is the maximum number of concurrent MySQL connections possible?

like image 990
user2075703 Avatar asked Feb 15 '13 18:02

user2075703


People also ask

How many concurrent connections can MySQL handle?

Each database user is limited to 38 simultaneous MySQL connections. This limitation helps to prevent overloading the MySQL server to the detriment of other sites hosted on the server.

How many connections can a MySQL database have?

MySQL Connection Limits At provision, Databases for MySQL sets the maximum number of connections to your MySQL database to 200. You can raise this value by Changing the MySQL Configuration.

What should be max connections in MySQL?

The system variable max_connections determines the number of connections which MySQL/MariaDB will accept. The default value is 151 connections, which allows 150 normal connections plus one connection from the SUPER account.


2 Answers

As per the MySQL docs: http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_max_user_connections

 maximum range: 4,294,967,295  (e.g. 2**32 - 1) 

You'd probably run out of memory, file handles, and network sockets, on your server long before you got anywhere close to that limit.

like image 80
Marc B Avatar answered Sep 27 '22 19:09

Marc B


You might have 10,000 users total, but that's not the same as concurrent users. In this context, concurrent scripts being run.

For example, if your visitor visits index.php, and it makes a database query to get some user details, that request might live for 250ms. You can limit how long those MySQL connections live even further by opening and closing them only when you are querying, instead of leaving it open for the duration of the script.

While it is hard to make any type of formula to predict how many connections would be open at a time, I'd venture the following:

You probably won't have more than 500 active users at any given time with a user base of 10,000 users. Of those 500 concurrent users, there will probably at most be 10-20 concurrent requests being made at a time.

That means, you are really only establishing about 10-20 concurrent requests.

As others mentioned, you have nothing to worry about in that department.

like image 39
crush Avatar answered Sep 27 '22 19:09

crush