Skip to content

Question: Role of mincached? #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cquptzzy opened this issue Sep 19, 2023 · 4 comments
Closed

Question: Role of mincached? #50

cquptzzy opened this issue Sep 19, 2023 · 4 comments

Comments

@cquptzzy
Copy link

Hello, first of all, I am not a native English speaker, so my expression may not be clear.
I want to determine the role of mincached
In the parameter introduction it is like this,
mincached: the initial number of idle connections in the pool (the default of 0 means no connections are made at startup)

But there is this sentence in the introduction of pooleddb:
Besides the pool of shared connections, you can also set up a pool of at least mincached and at the most maxcached idle connections that will be used whenever a thread is requesting a dedicated database connection or the pool of shared connections is not yet full.

Will pooleddb keep the connection based on mincached?
Can this connection be observed using show processlist?
Thank you so much

@Cito Cito changed the title role of mincached Question: Role of mincached? Sep 21, 2023
@Cito
Copy link
Member

Cito commented Sep 21, 2023

As I understand you're using DbUtils with MySQL as database and the PooledDb conection pool.

The role of mincached is illustrated here.

It's the number of connections that are at created in the pool and that will stay at minimum in the pool.

Yes, you can view these connections with show processlist.

For instance, if you set up the pool like this, you should see 10 connections in the list:

db = PooledDB(pymysql, mincached=10)

When the program exists or db is closed, the connections should disappear again.

It works similarly with other databases like PostgreSQL.

I hope this answers your questions.

@cquptzzy
Copy link
Author

Thank you very much. I see what you mean. It determines the number of connections at initialization and holds them. But it might automatically increase the number of connections as the number of requests gets larger, right?

@Cito
Copy link
Member

Cito commented Sep 21, 2023

But it might automatically increase the number of connections as the number of requests gets larger, right?

Right. The upper limit is controlled with the maxcached parameter. When this limit is reached, no more connections are created, and you need to wait until one of the used connections is freed and put back into the pool.

@cquptzzy
Copy link
Author

ok ,I got it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants