I'm confused about concurrent MySQL connections

前端 未结 6 1767
走了就别回头了
走了就别回头了 2021-02-14 01:14

So, I read a book in Mysql and it says that there\'s a limit on how many concurrent users that can access a database.

Does that mean that If I have 20k users browsing i

6条回答
  •  天命终不由人
    2021-02-14 01:34

    20k users loading a page at the exact same time ? That's quite a lot -- and your webserver will probably not accept that many concurrent requests itself (For example, Apache generally accepts only between 200 and 400 parallel requests).

    The connection limit is the maximum number of users that can be connecter to your database at the exact same time -- if each page needs 100 ms to be generated, one user will only be connected for less than 100 ms.
    And if you connect to your database just when you need to do your first SQL query, and disconnect immediately after your last SQL query, this can reduce the time during which your Webserver is connected to the DB.

    If you have users reading content from your website, you can consider they will :

    • Load a page (maybe 100 ms on your server)
    • Do nothing but read for a couple of minutes (which takes absolutly no resource on your server)


    As a sidenote : quite a long time before getting 20k concurrent connections (which means about 20,000 connections per second or so !), you'll probably have to deal with several scaling-relating problems...

提交回复
热议问题