Albirew/nyaa-pantsu
Albirew
/
nyaa-pantsu
Archivé
1
0
Bifurcation 0

Reduce MaxOpenConn to increase performance (#1101)

Cette révision appartient à :
tomleb 2017-07-03 21:43:38 -04:00 révisé par ewhal
Parent 2319b67fef
révision f283dfc5ce
1 fichiers modifiés avec 7 ajouts et 9 suppressions

Voir le fichier

@ -57,15 +57,13 @@ func GormInit(conf *config.Config, logger Logger) (*gorm.DB, error) {
return nil, connectionErr
}
// Negative MaxIdleConns means don't retain any idle connection
maxIdleConns := -1
if IsSqlite {
// sqlite doesn't like having a negative maxIdleConns
maxIdleConns = 10
}
db.DB().SetMaxIdleConns(maxIdleConns)
db.DB().SetMaxOpenConns(400)
db.DB().SetMaxIdleConns(1)
// This should be about the number of cores the machine has (and should
// be lower than the max_connection specified by postgresql.conf)
// Since we have two applications running, this should really be
// number of cores / 2
// TODO Make configurable
db.DB().SetMaxOpenConns(4)
if config.Conf.Environment == "DEVELOPMENT" {
db.LogMode(true)