Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sequelize - connection pool size

now i`m reading an article on http://docs.sequelizejs.com/manual/installation/getting-started.html

and cannot understand this sentences written below.

If you're connecting to the DB from multiple processes, you'll have to create one instance per process, but each instance should have a maximum connection pool size of "max connection pool size divided by number of instances". So, if you wanted a max connection pool size of 90 and you had 3 worker processes, each process's instance should have a max connection pool size of 30.

pool: {
  max: 5,
  min: 0,
  idle: 10000
}

what the connection pool size? is that meaning the max?

i am now understanding the connection-pool like this. if "max" is 5, and 3users want to get to the DB, 3 connections are allocated to the individual user.

and if 6users want to get the DB, 5connections are all allocated to the individual user, and since there is only 5 connections, the 6th user has to wait.

so i cannot make any sense of

each instance should have a maximum connection pool size of "max connection pool size divided by number of instances".

can anyone please explain about this?

like image 521
jwkoo Avatar asked Sep 10 '17 04:09

jwkoo


1 Answers

This is a very broad question but here is very broad overview

Whenever we connection to db server, it actually forks a new process to fulfill that request. As you can expect, this is expensive. So pool allows us to keep the number of processes active in db server. max means that no matter how many request your app(node) gets, it will not open up a new process with the db server.

and if 6users want to get the DB, 5connections are all allocated to the individual user, and since there is only 5 connections, the 6th user has to wait.

In the above case, only 5 parallel request can run with the db server (not the app server)

Here is a good link to read

like image 71
AbhinavD Avatar answered Sep 28 '22 17:09

AbhinavD