简体   繁体   中英

Is mysql concurrent connection limit per mysql user or limit per localhost

I'm new here but got log of benefit from this site. I'm planning on large php/mysql website, but confusing about mysql concurrent connection limit. Is that limit per mysql database or limit per localhost/cpanel account? If it limit per mysql database. So in case I have a dedicated mysql database for each end-user, then for example 1000 databases per 1000 end-user, but I only have 1 mysql-user that grant access to that all 1000 databases. Can it be ok? If it limit per mysql-user. Is pool connections can be a solution this case?

There are system variables to control both. As stated in the manual :

  • max_connections

    \n+----------------------+-----------------------+ \n|  Command-Line Format |  --max_connections=# | \n+----------------------+-----------------------+ \n|  Option-File Format |  max_connections | \n+----------------------+-----------------------+ \n|  Option Sets Variable |  Yes, max_connections | \n+----------------------+-----------------------+ \n|  Variable Name |  max_connections | \n+----------------------+-----------------------+ \n|  Variable Scope |  Global | \n+----------------------+-----------------------+ \n|  Dynamic Variable |  Yes | \n+----------------------+-----------------------+ \n|  |  Permitted Values | \n+  +---------+-------------+ \n|  |  Type |  numeric | \n+  +---------+-------------+ \n|  |  Default |  151 | \n+  +---------+-------------+ \n|  |  Range |  1 .. 100000 | \n+----------------------+-----------------------+ \n

    The maximum permitted number of simultaneous client connections. By default, this is 151. See Section C.5.2.7, “ Too many connections , for more information.

    Increasing this value increases the number of file descriptors that mysqld requires. See Section 8.4.3.1, “How MySQL Opens and Closes Tables” , for comments on file descriptor limits.

  • max_user_connections

    \n+----------------------+---------------------------+ \n|  Command-Line Format |  --max_user_connections=# | \n+----------------------+---------------------------+ \n|  Option-File Format |  max_user_connections | \n+----------------------+---------------------------+ \n|  Option Sets Variable |  Yes, max_user_connections | \n+----------------------+---------------------------+ \n|  Variable Name |  max_user_connections | \n+----------------------+---------------------------+ \n|  Variable Scope |  Global, Session | \n+----------------------+---------------------------+ \n|  Dynamic Variable |  Yes | \n+----------------------+---------------------------+ \n|  |  Permitted Values | \n+  +---------+-----------------+ \n|  |  Type |  numeric | \n+  +---------+-----------------+ \n|  |  Default |  0 | \n+  +---------+-----------------+ \n|  |  Range |  0 .. 4294967295 | \n+----------------------+---------------------------+ \n

    The maximum number of simultaneous connections permitted to any given MySQL user account. A value of 0 (the default) means “no limit.”

    This variable has a global value that can be set at server startup or runtime. It also has a read-only session value that indicates the effective simultaneous-connection limit that applies to the account associated with the current session. The session value is initialized as follows:

    If the user account has a nonzero MAX_USER_CONNECTIONS resource limit, the session max_user_connections value is set to that limit.

    Otherwise, the session max_user_connections value is set to the global value.

    Account resource limits are specified using the GRANT statement. See Section 6.3.4, “Setting Account Resource Limits” , and Section 13.7.1.3, “ GRANT Syntax” .

That's crazy. You can't have 1 database for each user. That's an over kill. (if you are not a hosting provider)

Anyway MySQL suggest to don't over come 4096 concurrent requests per machine. I believe you will have many other problems than database if you will ever have 4096 concurrent requests.

Reference: MySQL Best Pratices

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM