Skip to content

Commit f00f9ee

Browse files
authored
Add PollerInitCount and lower default PollerMaxCount (#1433)
What changed? When autoscaling is enabled, initial poller count should start from MaxConcurrentActivityTaskPollers so it's same behavior when autoscaling is not enabled. change default max number to 20 Why? Jump to max would potentially congest network connections.
1 parent ebff2b1 commit f00f9ee

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

internal/internal_poller_autoscaler.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ import (
2828
const (
2929
defaultPollerAutoScalerCooldown = 10 * time.Second
3030
defaultMinPollerSize = 2
31-
defaultMaxPollerSize = 200
31+
defaultMaxPollerSize = 20
32+
defaultInitPollerSize = 2
3233
defaultPollerAutoScalerWaitTimeUpperBound = 256 * time.Millisecond
3334
defaultPollerAutoScalerWaitTimeLowerBound = 16 * time.Millisecond
3435
)
@@ -48,9 +49,13 @@ type (
4849
PollerMinCount int
4950

5051
// Optional: The maximum number of pollers to start with.
51-
// default: 200
52+
// default: 20
5253
PollerMaxCount int
5354

55+
// Optional: The initial number of pollers to start with.
56+
// default: 2
57+
PollerInitCount int
58+
5459
// Optional: The upper bound of poller wait time for poller autoscaler to scale down.
5560
// default: 256ms
5661
// NOTE: This is normally not needed to be set by user.

internal/internal_worker.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,13 @@ func newWorkflowTaskWorkerInternal(
276276
domain,
277277
params,
278278
)
279+
pollerCount := params.MaxConcurrentDecisionTaskPollers
280+
if params.AutoScalerOptions.Enabled {
281+
pollerCount = params.AutoScalerOptions.PollerInitCount
282+
}
279283
worker := newBaseWorker(baseWorkerOptions{
280284
pollerAutoScaler: params.AutoScalerOptions,
281-
pollerCount: params.MaxConcurrentDecisionTaskPollers,
285+
pollerCount: pollerCount,
282286
pollerRate: defaultPollerRate,
283287
maxConcurrentTask: params.MaxConcurrentDecisionTaskExecutionSize,
284288
maxTaskPerSecond: params.WorkerDecisionTasksPerSecond,
@@ -470,7 +474,7 @@ func newActivityTaskWorker(
470474
ensureRequiredParams(&workerParams)
471475
pollerCount := workerParams.MaxConcurrentActivityTaskPollers
472476
if workerParams.AutoScalerOptions.Enabled {
473-
pollerCount = workerParams.AutoScalerOptions.PollerMaxCount
477+
pollerCount = workerParams.AutoScalerOptions.PollerInitCount
474478
}
475479
base := newBaseWorker(
476480
baseWorkerOptions{
@@ -1301,6 +1305,9 @@ func augmentAutoScalerOptions(options AutoScalerOptions) AutoScalerOptions {
13011305
if options.PollerMaxCount <= 1 {
13021306
options.PollerMaxCount = defaultMaxPollerSize
13031307
}
1308+
if options.PollerInitCount <= 1 {
1309+
options.PollerInitCount = defaultInitPollerSize
1310+
}
13041311
if options.Cooldown == 0 {
13051312
options.Cooldown = defaultPollerAutoScalerCooldown
13061313
}

internal/internal_worker_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1326,6 +1326,7 @@ func Test_augmentWorkerOptions(t *testing.T) {
13261326
Enabled: true,
13271327
PollerMinCount: 10,
13281328
PollerMaxCount: 20,
1329+
PollerInitCount: 5,
13291330
Cooldown: time.Minute * 3,
13301331
PollerWaitTimeUpperBound: time.Millisecond * 200,
13311332
PollerWaitTimeLowerBound: time.Millisecond * 100,
@@ -1366,6 +1367,7 @@ func Test_augmentWorkerOptions(t *testing.T) {
13661367
Enabled: true,
13671368
PollerMinCount: 10,
13681369
PollerMaxCount: 20,
1370+
PollerInitCount: 5,
13691371
Cooldown: time.Minute * 3,
13701372
PollerWaitTimeUpperBound: time.Millisecond * 200,
13711373
PollerWaitTimeLowerBound: time.Millisecond * 100,
@@ -1409,7 +1411,8 @@ func Test_augmentWorkerOptions(t *testing.T) {
14091411
AutoScalerOptions: AutoScalerOptions{
14101412
Enabled: false,
14111413
PollerMinCount: 2,
1412-
PollerMaxCount: 200,
1414+
PollerMaxCount: 20,
1415+
PollerInitCount: 2,
14131416
Cooldown: time.Second * 10,
14141417
PollerWaitTimeUpperBound: time.Millisecond * 256,
14151418
PollerWaitTimeLowerBound: time.Millisecond * 16,

0 commit comments

Comments
 (0)