Skip to content

Commit 37c9944

Browse files
Bueller87“Kevin”
andauthored
Fix Autoscaling-Monitoring Sample Bugs (#104)
* Fix config file loading errors * Add a slightly higher load as the default to trigger worker autoscaling * Change Burst and Sustained load suggestions * Add implementation to documented cmd line flag -config --------- Co-authored-by: “Kevin” <“[email protected]”>
1 parent 9229fa8 commit 37c9944

File tree

5 files changed

+53
-25
lines changed

5 files changed

+53
-25
lines changed

cmd/samples/advanced/autoscaling-monitoring/README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ autoscaling:
8282
# Load generation settings
8383
loadGeneration:
8484
# Workflow-level settings
85-
workflows: 3 # Number of workflows to start
85+
workflows: 10 # Number of workflows to start
8686
workflowDelay: 1000 # Delay between starting workflows (milliseconds)
8787

8888
# Activity-level settings (per workflow)
89-
activitiesPerWorkflow: 40 # Number of activities per workflow
89+
activitiesPerWorkflow: 30 # Number of activities per workflow
9090
batchDelay: 2000 # Delay between activity batches within workflow (milliseconds)
9191

9292
# Activity processing time range (milliseconds)
@@ -126,9 +126,9 @@ autoscaling:
126126
pollerMaxCount: 8
127127
pollerInitCount: 4
128128
loadGeneration:
129-
workflows: 3
129+
workflows: 10
130130
workflowDelay: 1000
131-
activitiesPerWorkflow: 40
131+
activitiesPerWorkflow: 30
132132
batchDelay: 2000
133133
minProcessingTime: 1000
134134
maxProcessingTime: 6000
@@ -141,29 +141,29 @@ The sample supports various load patterns for testing autoscaling behavior:
141141
#### **1. Gradual Ramp-up (Default)**
142142
```yaml
143143
loadGeneration:
144-
workflows: 3
144+
workflows: 10
145145
workflowDelay: 1000
146-
activitiesPerWorkflow: 40
146+
activitiesPerWorkflow: 30
147147
```
148-
**Result**: 3 workflows starting 1 second apart, each with 40 activities (120 total activities)
148+
**Result**: 10 workflows starting 1 second apart, each with 30 activities (300 total activities)
149149

150150
#### **2. Burst Load**
151151
```yaml
152152
loadGeneration:
153-
workflows: 10
153+
workflows: 25
154154
workflowDelay: 0
155-
activitiesPerWorkflow: 20
155+
activitiesPerWorkflow: 60
156156
```
157-
**Result**: 10 workflows all starting immediately (200 total activities)
157+
**Result**: 25 workflows all starting immediately (1500 total activities)
158158

159159
#### **3. Sustained Load**
160160
```yaml
161161
loadGeneration:
162-
workflows: 5
163-
workflowDelay: 5000
162+
workflows: 50
163+
workflowDelay: 2000
164164
activitiesPerWorkflow: 100
165165
```
166-
**Result**: 5 long-running workflows with 5-second delays between starts (500 total activities)
166+
**Result**: 5 long-running workflows with 2-second delays between starts (5000 total activities)
167167

168168
#### **4. Light Load**
169169
```yaml

cmd/samples/advanced/autoscaling-monitoring/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ const (
5656
DefaultPollerMaxCount = 8
5757
DefaultPollerInitCount = 4
5858

59-
DefaultWorkflows = 3
59+
DefaultWorkflows = 10
6060
DefaultWorkflowDelay = 1000
61-
DefaultActivitiesPerWorkflow = 40
61+
DefaultActivitiesPerWorkflow = 30
6262
DefaultBatchDelay = 2000
6363
DefaultMinProcessingTime = 1000
6464
DefaultMaxProcessingTime = 6000

cmd/samples/advanced/autoscaling-monitoring/config/autoscaling.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ autoscaling:
1818
# Worker load simulation settings
1919
loadGeneration:
2020
# Workflow-level settings
21-
workflows: 3 # Number of workflows to start
22-
workflowDelay: 400 # Delay between starting workflows (milliseconds)
21+
workflows: 10 # Number of workflows to start
22+
workflowDelay: 1000 # Delay between starting workflows (milliseconds)
2323

2424
# Activity-level settings (per workflow)
25-
activitiesPerWorkflow: 40 # Number of activities per workflow
25+
activitiesPerWorkflow: 30 # Number of activities per workflow
2626
batchDelay: 750 # Delay between activity batches within workflow (milliseconds)
2727

2828
# Activity processing time range (milliseconds)

cmd/samples/advanced/autoscaling-monitoring/config_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ autoscaling:
2222
pollerMaxCount: 10
2323
pollerInitCount: 5
2424
loadGeneration:
25-
workflows: 5
26-
workflowDelay: 3
27-
activitiesPerWorkflow: 100
25+
workflows: 10
26+
workflowDelay: 1000
27+
activitiesPerWorkflow: 30
2828
batchDelay: 5
2929
minProcessingTime: 2000
3030
maxProcessingTime: 8000
@@ -51,9 +51,9 @@ autoscaling:
5151
assert.Equal(t, 3, config.Autoscaling.PollerMinCount)
5252
assert.Equal(t, 10, config.Autoscaling.PollerMaxCount)
5353
assert.Equal(t, 5, config.Autoscaling.PollerInitCount)
54-
assert.Equal(t, 5, config.Autoscaling.LoadGeneration.Workflows)
55-
assert.Equal(t, 3, config.Autoscaling.LoadGeneration.WorkflowDelay)
56-
assert.Equal(t, 100, config.Autoscaling.LoadGeneration.ActivitiesPerWorkflow)
54+
assert.Equal(t, 10, config.Autoscaling.LoadGeneration.Workflows)
55+
assert.Equal(t, 1000, config.Autoscaling.LoadGeneration.WorkflowDelay)
56+
assert.Equal(t, 30, config.Autoscaling.LoadGeneration.ActivitiesPerWorkflow)
5757
assert.Equal(t, 5, config.Autoscaling.LoadGeneration.BatchDelay)
5858
assert.Equal(t, 2000, config.Autoscaling.LoadGeneration.MinProcessingTime)
5959
assert.Equal(t, 8000, config.Autoscaling.LoadGeneration.MaxProcessingTime)

cmd/samples/advanced/autoscaling-monitoring/main.go

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"net/http"
77
"os"
8+
"path/filepath"
89
"time"
910

1011
"github.com/pborman/uuid"
@@ -20,14 +21,41 @@ const (
2021
ApplicationName = "autoscaling-monitoring"
2122
)
2223

24+
// findConfigFile finds the config file relative to the executable location
25+
func findConfigFile() string {
26+
// Get the directory where the executable is located
27+
execPath, err := os.Executable()
28+
if err != nil {
29+
// Fallback to current working directory if we can't determine executable path
30+
return "config/autoscaling.yaml"
31+
}
32+
execDir := filepath.Dir(execPath)
33+
34+
// Try to find the config file relative to the executable
35+
// The executable is in bin/, so we need to go up to the repo root and then to the config
36+
configPath := filepath.Join(execDir, "..", "cmd", "samples", "advanced", "autoscaling-monitoring", "config", "autoscaling.yaml")
37+
38+
// Check if the config file exists at this path
39+
if _, err := os.Stat(configPath); err == nil {
40+
return configPath
41+
}
42+
43+
// Fallback to the original relative path (for development when running with go run)
44+
return "config/autoscaling.yaml"
45+
}
46+
2347
func main() {
2448
// Parse command line arguments
2549
var mode string
50+
var configFile string
2651
flag.StringVar(&mode, "m", "worker", "Mode: worker or trigger")
52+
flag.StringVar(&configFile, "config", "", "Path to configuration file")
2753
flag.Parse()
2854

2955
// Load configuration
30-
configFile := "config/autoscaling.yaml"
56+
if configFile == "" {
57+
configFile = findConfigFile()
58+
}
3159
config := loadConfiguration(configFile)
3260

3361
// Setup common helper with our configuration

0 commit comments

Comments
 (0)