mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-10 22:17:44 +00:00
tweak pool args
This commit is contained in:
parent
56d72d5dea
commit
e46082949a
4 changed files with 12 additions and 7 deletions
|
@ -32,7 +32,7 @@ func APICmd(ctx context.Context) *cobra.Command {
|
||||||
}
|
}
|
||||||
defer statsd.Close()
|
defer statsd.Close()
|
||||||
|
|
||||||
db, err := cmdutil.NewDatabasePool(ctx)
|
db, err := cmdutil.NewDatabasePool(ctx, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ func SchedulerCmd(ctx context.Context) *cobra.Command {
|
||||||
}
|
}
|
||||||
defer statsd.Close()
|
defer statsd.Close()
|
||||||
|
|
||||||
db, err := cmdutil.NewDatabasePool(ctx)
|
db, err := cmdutil.NewDatabasePool(ctx, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,9 @@ func WorkerCmd(ctx context.Context) *cobra.Command {
|
||||||
}
|
}
|
||||||
defer statsd.Close()
|
defer statsd.Close()
|
||||||
|
|
||||||
db, err := cmdutil.NewDatabasePool(ctx)
|
consumers := runtime.NumCPU() * multiplier
|
||||||
|
|
||||||
|
db, err := cmdutil.NewDatabasePool(ctx, multiplier)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -60,8 +62,6 @@ func WorkerCmd(ctx context.Context) *cobra.Command {
|
||||||
return fmt.Errorf("invalid queue: %s", queueID)
|
return fmt.Errorf("invalid queue: %s", queueID)
|
||||||
}
|
}
|
||||||
|
|
||||||
consumers := runtime.NumCPU() * multiplier
|
|
||||||
|
|
||||||
worker := workerFn(logger, statsd, db, redis, queue, consumers)
|
worker := workerFn(logger, statsd, db, redis, queue, consumers)
|
||||||
worker.Start()
|
worker.Start()
|
||||||
|
|
||||||
|
|
|
@ -50,8 +50,13 @@ func NewRedisClient(ctx context.Context) (*redis.Client, error) {
|
||||||
return client, nil
|
return client, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDatabasePool(ctx context.Context) (*pgxpool.Pool, error) {
|
func NewDatabasePool(ctx context.Context, maxConns int) (*pgxpool.Pool, error) {
|
||||||
url := fmt.Sprintf("%s?sslmode=require&pool_max_conns=32", os.Getenv("DATABASE_CONNECTION_POOL_URL"))
|
url := fmt.Sprintf(
|
||||||
|
"%s?sslmode=require&pool_max_conns=%d&pool_min_conns=%d",
|
||||||
|
os.Getenv("DATABASE_CONNECTION_POOL_URL"),
|
||||||
|
maxConns,
|
||||||
|
maxConns/8,
|
||||||
|
)
|
||||||
config, err := pgxpool.ParseConfig(url)
|
config, err := pgxpool.ParseConfig(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in a new issue