-
Notifications
You must be signed in to change notification settings - Fork 2.3k
README: Recommend some DB settings #1141
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
Conversation
Co-authored-by: Ichinose Shogo <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The README now says "Since some middlewares close idle connections by 5 minutes,". Could you be more precise about which middlewares you are talking about? |
https://golang.org/pkg/database/sql/#DB.SetMaxOpenConns
so |
I wrote "same to (or greater than)" because greater value become same value automatically. |
@methane can you explain why you suggest to set max open connections equal to max idle connections? |
I explained it already. "When it is smaller than
It looks like what you see is what I said. DB opens new connection because no idle connections. You didn't see high number of InUse just because number of InUse connections is moving like "spike", and your sampling rate is too slow to catch the spike. You should try this as I recommended in the README. db.SetMaxOpenConns(100)
db.SetMaxIdleConns(100)
db.SetConnMaxLifetime(time.Minute * 3) If you can not believe me, you should get |
Description
Recommend
SetConnMaxLifetime
,SetMaxOpenConns
, andSetMaxIdleConns
.Checklist