Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions cmd/samples/advanced/autoscaling-monitoring/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ autoscaling:
# Load generation settings
loadGeneration:
# Workflow-level settings
workflows: 3 # Number of workflows to start
workflows: 10 # Number of workflows to start
workflowDelay: 1000 # Delay between starting workflows (milliseconds)

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

# Activity processing time range (milliseconds)
Expand Down Expand Up @@ -126,9 +126,9 @@ autoscaling:
pollerMaxCount: 8
pollerInitCount: 4
loadGeneration:
workflows: 3
workflows: 10
workflowDelay: 1000
activitiesPerWorkflow: 40
activitiesPerWorkflow: 30
batchDelay: 2000
minProcessingTime: 1000
maxProcessingTime: 6000
Expand All @@ -141,29 +141,29 @@ The sample supports various load patterns for testing autoscaling behavior:
#### **1. Gradual Ramp-up (Default)**
```yaml
loadGeneration:
workflows: 3
workflows: 10
workflowDelay: 1000
activitiesPerWorkflow: 40
activitiesPerWorkflow: 30
```
**Result**: 3 workflows starting 1 second apart, each with 40 activities (120 total activities)
**Result**: 10 workflows starting 1 second apart, each with 30 activities (300 total activities)

#### **2. Burst Load**
```yaml
loadGeneration:
workflows: 10
workflows: 25
workflowDelay: 0
activitiesPerWorkflow: 20
activitiesPerWorkflow: 60
```
**Result**: 10 workflows all starting immediately (200 total activities)
**Result**: 25 workflows all starting immediately (1500 total activities)

#### **3. Sustained Load**
```yaml
loadGeneration:
workflows: 5
workflowDelay: 5000
workflows: 50
workflowDelay: 2000
activitiesPerWorkflow: 100
```
**Result**: 5 long-running workflows with 5-second delays between starts (500 total activities)
**Result**: 5 long-running workflows with 2-second delays between starts (5000 total activities)

#### **4. Light Load**
```yaml
Expand Down
4 changes: 2 additions & 2 deletions cmd/samples/advanced/autoscaling-monitoring/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ const (
DefaultPollerMaxCount = 8
DefaultPollerInitCount = 4

DefaultWorkflows = 3
DefaultWorkflows = 10
DefaultWorkflowDelay = 1000
DefaultActivitiesPerWorkflow = 40
DefaultActivitiesPerWorkflow = 30
DefaultBatchDelay = 2000
DefaultMinProcessingTime = 1000
DefaultMaxProcessingTime = 6000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ autoscaling:
# Worker load simulation settings
loadGeneration:
# Workflow-level settings
workflows: 3 # Number of workflows to start
workflowDelay: 400 # Delay between starting workflows (milliseconds)
workflows: 10 # Number of workflows to start
workflowDelay: 1000 # Delay between starting workflows (milliseconds)

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

# Activity processing time range (milliseconds)
Expand Down
12 changes: 6 additions & 6 deletions cmd/samples/advanced/autoscaling-monitoring/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ autoscaling:
pollerMaxCount: 10
pollerInitCount: 5
loadGeneration:
workflows: 5
workflowDelay: 3
activitiesPerWorkflow: 100
workflows: 10
workflowDelay: 1000
activitiesPerWorkflow: 30
batchDelay: 5
minProcessingTime: 2000
maxProcessingTime: 8000
Expand All @@ -51,9 +51,9 @@ autoscaling:
assert.Equal(t, 3, config.Autoscaling.PollerMinCount)
assert.Equal(t, 10, config.Autoscaling.PollerMaxCount)
assert.Equal(t, 5, config.Autoscaling.PollerInitCount)
assert.Equal(t, 5, config.Autoscaling.LoadGeneration.Workflows)
assert.Equal(t, 3, config.Autoscaling.LoadGeneration.WorkflowDelay)
assert.Equal(t, 100, config.Autoscaling.LoadGeneration.ActivitiesPerWorkflow)
assert.Equal(t, 10, config.Autoscaling.LoadGeneration.Workflows)
assert.Equal(t, 1000, config.Autoscaling.LoadGeneration.WorkflowDelay)
assert.Equal(t, 30, config.Autoscaling.LoadGeneration.ActivitiesPerWorkflow)
assert.Equal(t, 5, config.Autoscaling.LoadGeneration.BatchDelay)
assert.Equal(t, 2000, config.Autoscaling.LoadGeneration.MinProcessingTime)
assert.Equal(t, 8000, config.Autoscaling.LoadGeneration.MaxProcessingTime)
Expand Down
30 changes: 29 additions & 1 deletion cmd/samples/advanced/autoscaling-monitoring/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"net/http"
"os"
"path/filepath"
"time"

"github.com/pborman/uuid"
Expand All @@ -20,14 +21,41 @@ const (
ApplicationName = "autoscaling-monitoring"
)

// findConfigFile finds the config file relative to the executable location
func findConfigFile() string {
// Get the directory where the executable is located
execPath, err := os.Executable()
if err != nil {
// Fallback to current working directory if we can't determine executable path
return "config/autoscaling.yaml"
}
execDir := filepath.Dir(execPath)

// Try to find the config file relative to the executable
// The executable is in bin/, so we need to go up to the repo root and then to the config
configPath := filepath.Join(execDir, "..", "cmd", "samples", "advanced", "autoscaling-monitoring", "config", "autoscaling.yaml")

// Check if the config file exists at this path
if _, err := os.Stat(configPath); err == nil {
return configPath
}

// Fallback to the original relative path (for development when running with go run)
return "config/autoscaling.yaml"
}

func main() {
// Parse command line arguments
var mode string
var configFile string
flag.StringVar(&mode, "m", "worker", "Mode: worker or trigger")
flag.StringVar(&configFile, "config", "", "Path to configuration file")
flag.Parse()

// Load configuration
configFile := "config/autoscaling.yaml"
if configFile == "" {
configFile = findConfigFile()
}
config := loadConfiguration(configFile)

// Setup common helper with our configuration
Expand Down
Loading