Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NodeJS + MySql and large concurrent access

Tags:

node.js

mysql

So I have been writting this NodeJS Quiz App. At first we are not expecting that much users, but as time goes by we are looking at about ~50000 potential registered users. Considering the DB of choice iss MySql, and also considering not all registered users are going to be logged in at the same time, what is the maximum number of concurrent MySQL connections possible? Also, how much RAM and CPU would I need to host this app?

like image 404
Fabricio Ganzert Avatar asked Aug 16 '26 16:08

Fabricio Ganzert


1 Answers

When you are using node.js, you can simply use connection pooling, there is no obvious downside to pooling but you are establishing much less connection (and less overhead).

In addition, it all goes down to how much query is actually executed and how much execution time they need, here are some make up numbers:

Let's say if 50k users all go online at the same time, and each user makes 1 interaction per 5s and takes 10ms DB time to execute, then 50k * 10ms / 5s = 100 concurrent connection needed.

Of course you need to factor in some real numbers, and read-to-write ratio matters a lot (read can potentially run in parallel), and cache can help a lot if reading makes up large number of queries.

All in all, you are unlikely to need much if all you do is some simple select and insert per interaction.

PS This post gave some interesting number: with connection pooling, 5k connection = 100k concurrent user. Of course he/she didn't mention his/her load type, but you can see that (concurrent / connection threads) can be up to tens and hundred when connection pool is in place.

like image 118
Eric Wong Avatar answered Aug 18 '26 05:08

Eric Wong



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!