README: Recommend some DB settings#1141
Conversation
Co-authored-by: Ichinose Shogo <shogo82148@gmail.com>
|
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