mysql无法并发连接,我对并发MySQL连接感到困惑

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 in my web application concurrently, my web application will fail to load the data in my database? Because my web application is accessing the database every time my website loads.

解决方案

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...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值