Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions esignet-service/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ DATABASE_NAME=mosip_esignet
DATABASE_USERNAME=esignet
# DB_DBUSER_PASSWORD=secret

# Connection pool tuning (optional — defaults shown)
# DB_MAX_OPEN_CONNS=25
# DB_MAX_IDLE_CONNS=5
# Connection pool tuning (optional — defaults shown; the higher values below
# are tuned for production load, local/dev runs generally don't need them)
# DB_MAX_OPEN_CONNS=50
# DB_MAX_IDLE_CONNS=25
# DB_CONN_MAX_LIFETIME_SECS=1800 # 0 = no limit (explicit opt-out)
# DB_CONN_MAX_IDLE_TIME_SECS=300

Expand Down
12 changes: 6 additions & 6 deletions esignet-service/data/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ db:
# var of "0" opts *_lifetime_secs out to "no limit"; 0 here is treated as
# "not set".
pool:
max_open_conns: 25
max_idle_conns: 5 # kept well below max_open_conns: pgxpool eagerly
max_open_conns: 50
max_idle_conns: 25 # kept well below max_open_conns: pgxpool eagerly
Comment thread
anushasunkada marked this conversation as resolved.
# opens this many connections at startup (unlike
# database/sql's lazy MaxIdleConns), so a value
# equal to max_open_conns would force every
Expand All @@ -76,15 +76,15 @@ db:
# write_timeout_secs under inbound_http_server must exceed the combined
# timeout_secs of both clients below (see warnIfWriteTimeoutTooLow).
outbound_idsystem_http_client:
timeout_secs: 30
timeout_secs: 25
Comment thread
anushasunkada marked this conversation as resolved.
dial_timeout_secs: 5
dial_keep_alive_secs: 30
tls_handshake_timeout_secs: 10
response_header_timeout_secs: 10
idle_conn_timeout_secs: 90
max_conns_per_host: 500
max_idle_conns: 500
max_idle_conns_per_host: 200
max_conns_per_host: 1200
max_idle_conns: 1200
max_idle_conns_per_host: 800

outbound_http_client:
timeout_secs: 30
Expand Down
8 changes: 4 additions & 4 deletions esignet-service/internal/config/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const (
defaultDBPort = "5455"
defaultDBName = "mosip_esignet"
defaultDBUser = "postgres"
defaultDBMaxOpenConns = 25
defaultDBMaxOpenConns = 50
// defaultDBMaxIdleConns is intentionally well below defaultDBMaxOpenConns.
// Unlike database/sql's MaxIdleConns (a passive ceiling), pgxpool.Config's
// MinConns — which this feeds, see buildPoolConfig — is an eagerly
Expand All @@ -36,7 +36,7 @@ const (
// any traffic arrives, multiplying baseline Postgres load by replica
// count; keeping it low preserves warm-connection reuse under steady
// traffic while letting the pool grow lazily under load.
defaultDBMaxIdleConns = 5
defaultDBMaxIdleConns = 25
defaultDBConnMaxLifetimeSecs = 1800
defaultDBConnMaxIdleTimeSecs = 300
dbPingTimeout = 5 * time.Second
Expand Down Expand Up @@ -138,8 +138,8 @@ func resolveDBDSN(yamlDSN string) string {
//
// Pool tuning (all optional):
//
// DB_MAX_OPEN_CONNS — default 25
// DB_MAX_IDLE_CONNS — default 5
// DB_MAX_OPEN_CONNS — default 50
// DB_MAX_IDLE_CONNS — default 25
// DB_CONN_MAX_LIFETIME_SECS — default 1800 (0 = no limit, explicit env-var-only opt-out)
// DB_CONN_MAX_IDLE_TIME_SECS — default 300
func loadDB(yamlDB DB) DB {
Expand Down
18 changes: 14 additions & 4 deletions esignet-service/internal/config/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ import (
const (
defaultRedisHost = "localhost"
defaultRedisPort = "6379"
defaultRedisPoolSize = 10
defaultRedisMinIdleConns = 2
defaultRedisPoolSize = 100
defaultRedisMaxActiveConns = 100
defaultRedisMinIdleConns = 10
defaultRedisConnMaxIdleTime = 300
defaultRedisDialTimeoutSecs = 5
defaultRedisReadTimeoutSecs = 3
Expand Down Expand Up @@ -56,8 +57,11 @@ const (
// db.go, deployment.yaml documents these but they are never read from YAML,
// keeping a single source of truth for pool sizing):
//
// REDIS_POOL_SIZE — default 10
// REDIS_MIN_IDLE_CONNS — default 2
// REDIS_POOL_SIZE — default 100
// REDIS_MAX_ACTIVE_CONNS — default 100; hard ceiling on connections
// allocated by the pool at any given time
// (0 = no limit)
// REDIS_MIN_IDLE_CONNS — default 10
// REDIS_CONN_MAX_IDLE_TIME_SECS — default 300
// REDIS_CONN_MAX_LIFETIME_SECS — default 1800 (0 = no limit, explicit opt-out)
// REDIS_DIAL_TIMEOUT_SECS — default 5
Expand All @@ -76,6 +80,7 @@ type Redis struct {
TLS bool `yaml:"tls"`

PoolSize int `yaml:"-"`
MaxActiveConns int `yaml:"-"`
MinIdleConns int `yaml:"-"`
ConnMaxIdleTime time.Duration `yaml:"-"`
ConnMaxLifetime time.Duration `yaml:"-"`
Expand All @@ -99,6 +104,7 @@ func loadRedis(yamlRedis Redis) Redis {
// comment above), so fromYAML is always 0 — envIntOrConfigOrDefault
// collapses to "env wins if positive, else the compiled default".
poolSize := envIntOrConfigOrDefault("REDIS_POOL_SIZE", 0, defaultRedisPoolSize)
maxActiveConns := envIntOrConfigOrDefault("REDIS_MAX_ACTIVE_CONNS", 0, defaultRedisMaxActiveConns)
Comment thread
anushasunkada marked this conversation as resolved.
minIdle := envIntOrConfigOrDefault("REDIS_MIN_IDLE_CONNS", 0, defaultRedisMinIdleConns)
idleTime := time.Duration(envIntOrConfigOrDefault("REDIS_CONN_MAX_IDLE_TIME_SECS", 0, defaultRedisConnMaxIdleTime)) * time.Second

Expand Down Expand Up @@ -139,6 +145,7 @@ func loadRedis(yamlRedis Redis) Redis {
DB: envIntOrConfigOrDefault("REDIS_DB", yamlRedis.DB, defaultRedisDB),
TLS: envBoolOrConfig("REDIS_TLS_ENABLED", yamlRedis.TLS),
PoolSize: poolSize,
MaxActiveConns: maxActiveConns,
MinIdleConns: minIdle,
ConnMaxIdleTime: idleTime,
ConnMaxLifetime: lifetime,
Expand Down Expand Up @@ -191,6 +198,7 @@ func (r Redis) newClient() (*redis.Client, error) {
Password: r.Password,
DB: r.DB,
PoolSize: r.PoolSize,
MaxActiveConns: r.MaxActiveConns,
MinIdleConns: r.MinIdleConns,
ConnMaxIdleTime: r.ConnMaxIdleTime,
ConnMaxLifetime: r.ConnMaxLifetime,
Expand All @@ -211,6 +219,7 @@ func (r Redis) newClient() (*redis.Client, error) {
Password: r.Password,
DB: r.DB,
PoolSize: r.PoolSize,
MaxActiveConns: r.MaxActiveConns,
MinIdleConns: r.MinIdleConns,
ConnMaxIdleTime: r.ConnMaxIdleTime,
ConnMaxLifetime: r.ConnMaxLifetime,
Expand All @@ -229,6 +238,7 @@ func (r Redis) newClient() (*redis.Client, error) {
// The DSN may not encode pool parameters so we always override with explicit config.
func (r Redis) applyPool(opts *redis.Options) {
opts.PoolSize = r.PoolSize
opts.MaxActiveConns = r.MaxActiveConns
opts.MinIdleConns = r.MinIdleConns
opts.ConnMaxIdleTime = r.ConnMaxIdleTime
opts.ConnMaxLifetime = r.ConnMaxLifetime
Expand Down
8 changes: 4 additions & 4 deletions helm/esignet/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ resources:
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
limits:
cpu: 500m
memory: 2250Mi
cpu: '4'
memory: 3000Mi
requests:
cpu: 100m
cpu: '2'
memory: 1500Mi

additionalResources:
Expand All @@ -138,7 +138,7 @@ additionalResources:
## you change the memory limit. Set explicitly (e.g. "2025MiB") to override the 90%
## default, or if resources.limits.memory uses a unit auto-derivation can't parse
## (only Ki/Mi/Gi/Ti and unitless bytes are supported).
goMemLimit: ""
goMemLimit: "2700MiB"

## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container
## Clamav container already runs as 'mosip' user, so we may not need to enable this
Expand Down
6 changes: 3 additions & 3 deletions helm/oidc-ui/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ resources:
cpu: 300m
memory: 1500Mi
requests:
cpu: 100m
memory: 50Mi
cpu: 150m
memory: 750Mi

additionalResources:
## Specify any JAVA_OPTS string here. These typically will be specified in conjunction with above resources
## Example: java_opts: "-Xms500M -Xmx500M"
javaOpts: "-Xms750M -Xmx750M"
javaOpts: "-Xms500M -Xmx500M"

## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container
## Clamav container already runs as 'mosip' user, so we may not need to enable this
Expand Down
Loading