Skip to content

Configuration

Complete configuration reference for the Autoscaler components.

Nomadscaler Plugin Configuration

Scaling Policy

hcl
scaling "horizontal" {
  enabled = true
  min     = 1
  max     = 100

  policy {
    # Evaluation frequency
    evaluation_interval = "10s"

    # Minimum time between scaling actions
    cooldown = "30s"

    target "nomadscaler" {
      # Nomad job details
      namespace = "default"
      job       = "web-app"
      group     = "frontend"

      # Optimizer service
      optimizer_url = "http://optimizer:8000"

      # Cache configuration
      cache_size = 10  # seconds of predictions to cache

      # Metrics source
      metric_source = "nomad"  # "nomad" or "prometheus"
    }

    check "cpu_utilization" {
      source = "nomad-apm"
      query  = "avg_cpu_percent"

      strategy "target-value" {
        target = 75
      }
    }

    check "memory_utilization" {
      source = "nomad-apm"
      query  = "avg_memory_percent"

      strategy "target-value" {
        target = 80
      }
    }
  }
}

Configuration Parameters

ParameterTypeRequiredDefaultDescription
namespacestringYes-Nomad namespace
jobstringYes-Job name
groupstringYes-Task group name
optimizer_urlstringYes-Optimizer service URL
cache_sizeintNo10Prediction cache size (seconds)
metric_sourcestringNo"nomad"Metric source (nomad or prometheus)

Optimizer Service Configuration

config.ini

ini
[main]
loglevel=debug
api_loglevel=warning
only_test_data=true
enable_test_metrics=true
prometheus_url=http://localhost:9090
token=supersecrettoken

Configuration Parameters

ParameterTypeDefaultDescription
loglevelstringdebugLogging level (debug, info, warning, error)
api_loglevelstringwarningAPI/request logging level
only_test_databooleantrueUse bundled test data instead of real metrics
enable_test_metricsbooleantrueEnable test metrics endpoint for development
prometheus_urlstringhttp://localhost:9090Prometheus server URL for metrics retrieval
tokenstring-API authentication token (treat as secret)

Configuration Loading

The optimizer loads configuration from config.ini with the following resolution order:

  1. Path from CONFIG_PATH environment variable (if set)
  2. <base_dir>/config.ini
  3. <base_dir>/../config.ini

Example:

bash
# Override config path
export CONFIG_PATH=/path/to/custom/config.ini

# Run optimizer
poetry run web

SARIMAX Model Selection

The optimizer automatically selects the best SARIMAX model from multiple candidate orders using AIC (Akaike Information Criterion). The candidates are:

  • (1, 1, 1) - Standard ARIMA with differencing
  • (1, 0, 1) - ARMA without differencing (for stationary data)
  • (2, 1, 1) - Higher-order AR component
  • (1, 1, 0) - Pure AR model with differencing

The optimizer will fit all candidates and select the model with the lowest AIC.

MILP Solver Parameters

The MILP optimizer uses OR-Tools SCIP solver with the following default parameters:

  • replica_cost: Based on allocated CPU/memory with configurable weights
  • penalty: 1.0 (SLA violation cost)
  • startup_cost: 0.5 (cost to start new instances)
  • shutdown_cost: 0.3 (cost to stop instances)
  • max_scale_up: 2 (maximum instances to start per time step)
  • max_scale_down: 2 (maximum instances to stop per time step)

These parameters are hard-coded in the optimizer and tuned for general workloads. The capacity and replica costs are calculated dynamically based on allocated resources and the weights defined in weights.py.

Request Parameters

When calling the /optimize endpoint, you can configure:

cache_size

Number of seconds to predict ahead (default: 10):

json
{
  "cache_size": 10
}

Larger cache = more stable predictions, less frequent optimizer calls. Smaller cache = more responsive to changes.

min_replicas / max_replicas

Bounds for the optimization:

json
{
  "min_replicas": 1,
  "max_replicas": 10
}

current_replicas

Current state for optimal transitions:

json
{
  "current_replicas": 3
}

Development Mode

Test Data Mode

For local development and testing:

ini
[main]
only_test_data=true
enable_test_metrics=true

This uses bundled test data instead of querying real Prometheus metrics.

Production Mode

ini
[main]
only_test_data=false
enable_test_metrics=false
prometheus_url=http://prometheus:9090
token=PRODUCTION_SECRET_TOKEN

See Also