How sahiansalome14/auto-scaling-controller works
This repository’s product is a Go controller that continuously governs EC2 Auto Scaling capacity from CloudWatch and load-balancer signals. Its main workflow is observe, validate, decide, actuate, and record; a DynamoDB lease elects one active controller when leader election is enabled. The repository also supports k6-driven experiments and result analysis. Control-flow links follow the sampled controller code; experiment-analysis links reflect the documented workflow and visible load-generation utilities, not inspected orchestration internals.
Main entry points: main.go Controller loop · aws.go AWS provider · loadgen.js k6 load generator · provider.go Cloud interface
Components 20
Control loop
- Controller loop
cmd/controller/main.go - Configuration
cmd/controller/config.go - Observation
cmd/controller/observe.go - Scaling policy
cmd/controller/policy.go - Cloud interface
cmd/controller/provider.go - Decision log
- Persisted state
AWS integrations
- AWS provider
cmd/controller/aws.go - CloudWatch
- Auto Scaling Group
- Application Load Balancer
- EC2 application instances
High availability
- Leader elector
cmd/controller/leader.go - DynamoDB lease table
Experiments and analysis
- k6 load generator
loadgen/loadgen.js - Load profiles
loadgen/profiles - CSV converter
loadgen/k6_to_csv.py - Result plotting
scripts/plot_results.py - Experiment results
results
Other components
- Operator
Connections 24
- Operator → Controller loop: configures and starts
- Operator → k6 load generator: starts experiment
- Controller loop → Configuration: loads settings
- Controller loop → Persisted state: loads and saves
- Controller loop → Leader elector: checks leadership
- Leader elector → DynamoDB lease table: acquires or renews lease
- Controller loop → Observation: runs observation
- Observation → Cloud interface: fetches capacity and metrics
- Cloud interface → AWS provider: implemented by
- AWS provider → CloudWatch: queries metrics
- AWS provider → Auto Scaling Group: reads and sets capacity
- AWS provider → Application Load Balancer: reads target health
- Auto Scaling Group → EC2 application instances: manages capacity
- Application Load Balancer → EC2 application instances: routes traffic
- Controller loop → Scaling policy: evaluates observation
- Controller loop → Cloud interface: sets desired capacity
- Controller loop → Decision log: appends cycle record
- k6 load generator → Load profiles: uses stages from
- k6 load generator → Application Load Balancer: sends HTTP requests
- k6 load generator → CSV converter: produces raw CSV
- CSV converter → Experiment results: writes load metrics
- Decision log → Experiment results: collected per run
- Operator → Result plotting: analyzes run
- Result plotting → Experiment results: reads run data