Skip to content
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

Strange behavior when new connect with MinIdleConns #1681

Closed
zzjin opened this issue Mar 4, 2021 · 1 comment
Closed

Strange behavior when new connect with MinIdleConns #1681

zzjin opened this issue Mar 4, 2021 · 1 comment
Labels

Comments

@zzjin
Copy link

zzjin commented Mar 4, 2021

As document said:

// Minimum number of idle connections which is useful when establishing
// new connection is slow.
MinIdleConns int

Say set MinIdleConns something bigger like 4 * NumCPU, go redis will instant connect redis server 4xCPU connections and mark them all idle. code here

When in common use, (start one web server) all things goes right.
But when using for tests(or other parallel binary tasks) which default behavior is run each package in parallel, redis server will recive many many (4xCPUxpackage test file number) new connections.

One possible solution is set low idle connections in test files, but still wonder in real case we also no not need such new connections at first start. If we have slow redis connections this works worse.

Expected Behavior

Just connect small piece of new connections or provide another options to set such as StartConns int.

Current Behavior

Connect server as mush as idle connections options set..

Possible Solution

New 0 conn (or StartConns option) when new conn called, and inscrease double conns len when needed, and at end reach MinIdleConns or PoolSize

Possible Implementation

minPoolIncrease := p.poolSize*2
minIdleIncrease := p.idleConnsLen * 2
for p.poolSize < p.opt.PoolSize && p.idleConnsLen < p.opt.MinIdleConns && p.poolSize < minPoolIncrease && p.idleConnsLen < minIdleIncrease {
    ...
}
@github-actions
Copy link

This issue is marked stale. It will be closed in 30 days if it is not updated.

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

No branches or pull requests

1 participant