Skip to content

Configuration

Complete configuration reference for the Autoscaler components.

Nomadscaler Plugin Configuration

Scaling Policy

The productify-scaler is a strategy plugin — it is configured inside a policy check block:

hcl
scaling {
  enabled = true
  min     = 0
  max     = 10

  policy {
    # Evaluation frequency
    evaluation_interval = "3s"

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

    check "productify-scale-check" {
      source = "nomad-apm"
      query  = "avg_cpu-allocated"

      strategy "productify-scaler" {
        min             = 0
        max             = 10
        metric_app_name = "my-app"
        cache_size      = 10 # optional, default: 10
      }
    }
  }
}

The optimizer_token and optimizer_url can be supplied per check, or centrally in the autoscaler agent configuration:

hcl
strategy "productify-scaler" {
  driver = "productify-scaler"

  config = {
    optimizer_token = "supersecrettoken"
    optimizer_url   = "http://optimizer:8015"
  }
}

Configuration Parameters

ParameterTypeRequiredDefaultDescription
optimizer_tokenstringYes*-Authentication token for the optimizer API
optimizer_urlstringYes*-Optimizer service URL
minintYes-Minimum number of replicas
maxintYes-Maximum number of replicas
metric_app_namestringYes-Application name used in the optimizer's metric queries
cache_sizeintNo10Number of desired replica values to cache (seconds)

* May be provided in the per-check strategy config or in the agent-level strategy plugin config.

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
loglevelstringinfoLogging level (debug, info, warning, error)
api_loglevelstringinfoAPI server (uvicorn) logging level
only_test_databooleanfalseUse bundled test data instead of real metrics
enable_test_metricsbooleanfalseEnable the test metrics endpoint for development
prometheus_urlstring-Prometheus server URL for metrics retrieval
portint8015Port for the optimizer HTTP API
metrics_portint8017Port for the test metrics endpoint (if enabled)
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