mirror of
https://github.com/christianselig/apollo-backend
synced 2024-12-26 16:25:28 +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()
|
||||
|
||||
db, err := cmdutil.NewDatabasePool(ctx)
|
||||
db, err := cmdutil.NewDatabasePool(ctx, 32)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ func SchedulerCmd(ctx context.Context) *cobra.Command {
|
|||
}
|
||||
defer statsd.Close()
|
||||
|
||||
db, err := cmdutil.NewDatabasePool(ctx)
|
||||
db, err := cmdutil.NewDatabasePool(ctx, 32)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -38,7 +38,9 @@ func WorkerCmd(ctx context.Context) *cobra.Command {
|
|||
}
|
||||
defer statsd.Close()
|
||||
|
||||
db, err := cmdutil.NewDatabasePool(ctx)
|
||||
consumers := runtime.NumCPU() * multiplier
|
||||
|
||||
db, err := cmdutil.NewDatabasePool(ctx, multiplier)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -60,8 +62,6 @@ func WorkerCmd(ctx context.Context) *cobra.Command {
|
|||
return fmt.Errorf("invalid queue: %s", queueID)
|
||||
}
|
||||
|
||||
consumers := runtime.NumCPU() * multiplier
|
||||
|
||||
worker := workerFn(logger, statsd, db, redis, queue, consumers)
|
||||
worker.Start()
|
||||
|
||||
|
|
|
@ -50,8 +50,13 @@ func NewRedisClient(ctx context.Context) (*redis.Client, error) {
|
|||
return client, nil
|
||||
}
|
||||
|
||||
func NewDatabasePool(ctx context.Context) (*pgxpool.Pool, error) {
|
||||
url := fmt.Sprintf("%s?sslmode=require&pool_max_conns=32", os.Getenv("DATABASE_CONNECTION_POOL_URL"))
|
||||
func NewDatabasePool(ctx context.Context, maxConns int) (*pgxpool.Pool, error) {
|
||||
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)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Reference in a new issue