Skip to content

Commit b4568ab

Browse files
committed
Better lambdas formula
1 parent 88857bf commit b4568ab

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

goad.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func (t *Test) Start() <-chan queue.RegionsAggData {
7272
}
7373

7474
func (t *Test) invokeLambdas(awsConfig *aws.Config, sqsURL string) {
75-
lambdas := numberOfLambdas(t.config.Concurrency)
75+
lambdas := numberOfLambdas(t.config.Concurrency, len(t.config.Regions))
7676

7777
for i := 0; i < lambdas; i++ {
7878
region := t.config.Regions[i%len(t.config.Regions)]
@@ -115,10 +115,16 @@ func (t *Test) invokeLambda(awsConfig *aws.Config, args invokeArgs) {
115115
})
116116
}
117117

118-
func numberOfLambdas(concurrency uint) int {
118+
func numberOfLambdas(concurrency uint, numRegions int) int {
119+
if numRegions > int(concurrency) {
120+
return int(concurrency)
121+
}
119122
if concurrency/10 > 100 {
120123
return 100
121124
}
125+
if int(concurrency) < 10*numRegions {
126+
return numRegions
127+
}
122128
return int(concurrency-1)/10 + 1
123129
}
124130

0 commit comments

Comments
 (0)