increase consumers and make choice more direct

This commit is contained in:
Andre Medeiros 2022-10-31 17:33:41 -04:00
parent 62df908b33
commit df0860dd05
3 changed files with 15 additions and 16 deletions

View file

@ -50,7 +50,7 @@ func SchedulerCmd(ctx context.Context) *cobra.Command {
} }
defer db.Close() defer db.Close()
redis, err := cmdutil.NewRedisClient(ctx, 2) redis, err := cmdutil.NewRedisClient(ctx, 16)
if err != nil { if err != nil {
return err return err
} }

View file

@ -23,7 +23,7 @@ var (
) )
func WorkerCmd(ctx context.Context) *cobra.Command { func WorkerCmd(ctx context.Context) *cobra.Command {
var multiplier int var consumers int
var queueID string var queueID string
cmd := &cobra.Command{ cmd := &cobra.Command{
@ -46,10 +46,9 @@ func WorkerCmd(ctx context.Context) *cobra.Command {
} }
defer statsd.Close() defer statsd.Close()
consumers := runtime.NumCPU() * multiplier poolSize := consumers / 4
poolSize := multiplier / 4
runtime.GOMAXPROCS(multiplier) runtime.GOMAXPROCS(consumers)
db, err := cmdutil.NewDatabasePool(ctx, poolSize) db, err := cmdutil.NewDatabasePool(ctx, poolSize)
if err != nil { if err != nil {
@ -57,7 +56,7 @@ func WorkerCmd(ctx context.Context) *cobra.Command {
} }
defer db.Close() defer db.Close()
redis, err := cmdutil.NewRedisClient(ctx, multiplier) redis, err := cmdutil.NewRedisClient(ctx, consumers)
if err != nil { if err != nil {
return err return err
} }
@ -86,7 +85,7 @@ func WorkerCmd(ctx context.Context) *cobra.Command {
}, },
} }
cmd.Flags().IntVar(&multiplier, "multiplier", 32, "The multiplier (by CPUs) to run") cmd.Flags().IntVar(&consumers, "consumers", runtime.NumCPU()*64, "The consumers to run")
cmd.Flags().StringVar(&queueID, "queue", "", "The queue to work on") cmd.Flags().StringVar(&queueID, "queue", "", "The queue to work on")
return cmd return cmd

View file

@ -34,7 +34,7 @@ services:
- key: DEFAULT_POOL_SIZE - key: DEFAULT_POOL_SIZE
value: 178 value: 178
- key: MAX_CLIENT_CONN - key: MAX_CLIENT_CONN
value: 1024 value: 2048
- key: MIN_POOL_SIZE - key: MIN_POOL_SIZE
value: 8 value: 8
- key: POOL_MODE - key: POOL_MODE
@ -79,7 +79,7 @@ services:
- type: worker - type: worker
name: worker.notifications name: worker.notifications
env: go env: go
plan: starter plus plan: starter
envVars: envVars:
- fromGroup: env-settings - fromGroup: env-settings
- key: BUGSNAG_APP_TYPE - key: BUGSNAG_APP_TYPE
@ -87,11 +87,11 @@ services:
- key: BUGSNAG_METADATA_QUEUE - key: BUGSNAG_METADATA_QUEUE
value: notifications value: notifications
scaling: scaling:
minInstances: 2 minInstances: 20
maxInstances: 20 maxInstances: 50
targetCPUPercent: 60 targetCPUPercent: 60
buildCommand: go install github.com/bugsnag/panic-monitor@latest && go build ./cmd/apollo buildCommand: go install github.com/bugsnag/panic-monitor@latest && go build ./cmd/apollo
startCommand: panic-monitor ./apollo worker --queue notifications startCommand: panic-monitor ./apollo worker --queue notifications --consumers 512
# Stuck Notifications Checker # Stuck Notifications Checker
- type: worker - type: worker
@ -109,7 +109,7 @@ services:
maxInstances: 10 maxInstances: 10
targetCPUPercent: 60 targetCPUPercent: 60
buildCommand: go install github.com/bugsnag/panic-monitor@latest && go build ./cmd/apollo buildCommand: go install github.com/bugsnag/panic-monitor@latest && go build ./cmd/apollo
startCommand: panic-monitor ./apollo worker --queue stuck-notifications --multiplier 64 startCommand: panic-monitor ./apollo worker --queue stuck-notifications --consumers 64
# Scheduler # Scheduler
- type: worker - type: worker
@ -135,7 +135,7 @@ services:
- key: BUGSNAG_METADATA_QUEUE - key: BUGSNAG_METADATA_QUEUE
value: users value: users
buildCommand: go install github.com/bugsnag/panic-monitor@latest && go build ./cmd/apollo buildCommand: go install github.com/bugsnag/panic-monitor@latest && go build ./cmd/apollo
startCommand: panic-monitor ./apollo worker --queue users --multiplier 16 startCommand: panic-monitor ./apollo worker --queue users
# Subreddit Watcher # Subreddit Watcher
- type: worker - type: worker
@ -153,7 +153,7 @@ services:
maxInstances: 10 maxInstances: 10
targetCPUPercent: 60 targetCPUPercent: 60
buildCommand: go install github.com/bugsnag/panic-monitor@latest && go build ./cmd/apollo buildCommand: go install github.com/bugsnag/panic-monitor@latest && go build ./cmd/apollo
startCommand: panic-monitor ./apollo worker --queue subreddits --multiplier 64 startCommand: panic-monitor ./apollo worker --queue subreddits
# Trending Posts Watcher # Trending Posts Watcher
- type: worker - type: worker
@ -171,7 +171,7 @@ services:
maxInstances: 10 maxInstances: 10
targetCPUPercent: 60 targetCPUPercent: 60
buildCommand: go install github.com/bugsnag/panic-monitor@latest && go build ./cmd/apollo buildCommand: go install github.com/bugsnag/panic-monitor@latest && go build ./cmd/apollo
startCommand: panic-monitor ./apollo worker --queue trending --multiplier 64 startCommand: panic-monitor ./apollo worker --queue trending
# Live Activities # Live Activities
- type: worker - type: worker