Skip to content

Commit

Permalink
Update max open and idle postgresql connections. Update changelog.
Browse files Browse the repository at this point in the history
Default max idle connections is documented as 2:
https://golang.org/pkg/database/sql/#DB.SetMaxIdleConns
  • Loading branch information
brocaar committed Sep 27, 2019
1 parent a1edc2d commit 72d55f2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
13 changes: 9 additions & 4 deletions cmd/lora-app-server/cmd/configfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,19 @@ dsn="{{ .PostgreSQL.DSN }}"
# App Server and / or applying migrations.
automigrate={{ .PostgreSQL.Automigrate }}
# Max open connections in the pool.
# <= 0 means unlimited
# Max open connections.
#
# This sets the max. number of open connections that are allowed in the
# PostgreSQL connection pool (0 = unlimited).
max_open_connections={{ .PostgreSQL.MaxOpenConnections }}
# Max open connections in the pool.
# Zero means defaultMaxIdleConns; negative means 0
# Max idle connections.
#
# This sets the max. number of idle connections in the PostgreSQL connection
# pool (0 = no idle connections are retained).
max_idle_connections={{ .PostgreSQL.MaxIdleConnections }}
# Redis settings
#
# Please note that Redis 2.6.0+ is required.
Expand Down
3 changes: 1 addition & 2 deletions cmd/lora-app-server/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ func init() {
viper.SetDefault("general.password_hash_iterations", 100000)
viper.SetDefault("postgresql.dsn", "postgres://localhost/loraserver_as?sslmode=disable")
viper.SetDefault("postgresql.automigrate", true)
viper.SetDefault("postgresql.max_open_connections", -1)
viper.SetDefault("postgresql.max_idle_connections", 0)
viper.SetDefault("postgresql.max_idle_connections", 2)
viper.SetDefault("redis.url", "redis://localhost:6379")
viper.SetDefault("redis.max_idle", 10)
viper.SetDefault("redis.idle_timeout", 5*time.Minute)
Expand Down
12 changes: 12 additions & 0 deletions docs/content/install/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,18 @@ dsn="postgres://localhost/loraserver_as?sslmode=disable"
# App Server and / or applying migrations.
automigrate=true

# Max open connections.
#
# This sets the max. number of open connections that are allowed in the
# PostgreSQL connection pool (0 = unlimited).
max_open_connections=0

# Max idle connections.
#
# This sets the max. number of idle connections in the PostgreSQL connection
# pool (0 = no idle connections are retained).
max_idle_connections=2


# Redis settings
#
Expand Down
4 changes: 4 additions & 0 deletions docs/content/overview/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ the timezone for aggregation and metrics retention.
In the gateway list page, it is now possible to show a map showing all the
gateways and their states.

### Improvements

* Add PostgreSQL max open / idle connections settings. ([#360](https://github.com/brocaar/lora-app-server/pull/360)

### Upgrading

This release requires LoRa Server v3.3.0 or later (which will forward the
Expand Down

0 comments on commit 72d55f2

Please sign in to comment.