Skip to content

Configuration Reference

This page documents all configuration options for LXC AutoScale ML.

Configuration Files

ComponentPath
API/etc/lxc_autoscale_ml/lxc_autoscale_api.yaml
Model/etc/lxc_autoscale_ml/lxc_autoscale_ml.yaml
Monitor/etc/lxc_autoscale_ml/lxc_monitor.yaml

API Configuration

Complete Reference

yaml
# /etc/lxc_autoscale_ml/lxc_autoscale_api.yaml

# Server Configuration
server:
  host: "0.0.0.0"          # Bind address
  port: 5000               # Listen port

# Authentication
authentication:
  enabled: true            # Enable API key authentication
  api_key: "your-key"      # API key (change this!)

# Rate Limiting
rate_limiting:
  enabled: true            # Enable rate limiting
  max_requests_per_minute: 120  # Max requests per IP
  time_window_seconds: 60  # Sliding window duration

# Logging
logging:
  log_level: "INFO"        # DEBUG, INFO, WARNING, ERROR
  log_file: "/var/log/autoscaleapi.log"
  access_log: "/var/log/autoscaleapi_access.log"
  error_log: "/var/log/autoscaleapi_error.log"

API Options

OptionTypeDefaultDescription
server.hoststring0.0.0.0Network interface to bind
server.portinteger5000TCP port number
authentication.enabledbooleantrueRequire API key
authentication.api_keystring-Secret API key
rate_limiting.enabledbooleantrueEnable rate limits
rate_limiting.max_requests_per_minuteinteger120Request limit per IP
rate_limiting.time_window_secondsinteger60Window duration
logging.log_levelstringINFOMinimum log level

Model Configuration

Complete Reference

yaml
# /etc/lxc_autoscale_ml/lxc_autoscale_ml.yaml

# API Configuration
api:
  api_url: "http://127.0.0.1:5000"  # API base URL
  timeout: 5               # Request timeout (seconds)
  max_concurrent: 10       # Max parallel requests
  retry_attempts: 3        # Retry failed requests

# Data Configuration
data:
  metrics_file: "/var/log/lxc_metrics.json"

# Logging Configuration
logging:
  log_level: "INFO"        # DEBUG, INFO, WARNING, ERROR
  log_file: "/var/log/lxc_autoscale_ml.log"

# IsolationForest Configuration
isolation_forest:
  contamination: 0.1       # Expected anomaly fraction
  n_estimators: 100        # Number of trees
  random_state: 42         # Random seed
  max_samples: "auto"      # Samples per tree

# Scaling Configuration
scaling:
  # CPU Thresholds (percentage)
  cpu_scale_up_threshold: 70
  cpu_scale_down_threshold: 30
  cpu_scale_step: 1        # Cores to add/remove

  # RAM Thresholds (percentage)
  ram_scale_up_threshold: 80
  ram_scale_down_threshold: 40
  ram_scale_step_mb: 512   # MB to add/remove

  # Resource Limits
  min_cpu_cores: 1
  max_cpu_cores: 8
  min_ram_mb: 512
  max_ram_mb: 16384

  # Confidence
  min_confidence: 70       # Minimum confidence to scale

  # Testing
  dry_run: false           # Log decisions without executing

# Ignored Containers
ignore_lxc: []             # List of container IDs to skip

# Circuit Breaker
circuit_breaker:
  enabled: true
  failure_threshold: 5     # Failures before opening
  timeout_seconds: 300     # Time before reset

# Sleep Configuration
sleep_interval: 60         # Seconds between cycles

Model Options

API Settings

OptionTypeDefaultDescription
api.api_urlstringhttp://127.0.0.1:5000API base URL
api.timeoutinteger5Request timeout in seconds
api.max_concurrentinteger10Maximum parallel requests
api.retry_attemptsinteger3Retry count for failures

IsolationForest Settings

OptionTypeDefaultDescription
isolation_forest.contaminationfloat0.1Expected anomaly ratio (0.0-0.5)
isolation_forest.n_estimatorsinteger100Number of trees
isolation_forest.random_stateinteger42Random seed
isolation_forest.max_samplesstring/intautoSamples per tree

Scaling Settings

OptionTypeDefaultDescription
scaling.cpu_scale_up_thresholdinteger70CPU % to trigger scale up
scaling.cpu_scale_down_thresholdinteger30CPU % to trigger scale down
scaling.cpu_scale_stepinteger1CPU cores per scaling action
scaling.ram_scale_up_thresholdinteger80RAM % to trigger scale up
scaling.ram_scale_down_thresholdinteger40RAM % to trigger scale down
scaling.ram_scale_step_mbinteger512RAM MB per scaling action
scaling.min_cpu_coresinteger1Minimum CPU cores
scaling.max_cpu_coresinteger8Maximum CPU cores
scaling.min_ram_mbinteger512Minimum RAM (MB)
scaling.max_ram_mbinteger16384Maximum RAM (MB)
scaling.min_confidenceinteger70Minimum scaling confidence
scaling.dry_runbooleanfalseTest mode (no actual scaling)

Circuit Breaker Settings

OptionTypeDefaultDescription
circuit_breaker.enabledbooleantrueEnable circuit breaker
circuit_breaker.failure_thresholdinteger5Failures before opening
circuit_breaker.timeout_secondsinteger300Reset timeout

Other Settings

OptionTypeDefaultDescription
ignore_lxclist[]Container IDs to exclude
sleep_intervalinteger60Seconds between cycles

Monitor Configuration

Complete Reference

yaml
# /etc/lxc_autoscale_ml/lxc_monitor.yaml

# Metrics Configuration
metrics:
  output_file: "/var/log/lxc_metrics.json"
  max_entries: 1000        # Max entries in file
  collection_interval: 10  # Seconds between collections

# Logging Configuration
logging:
  log_level: "INFO"        # DEBUG, INFO, WARNING, ERROR
  log_file: "/var/log/lxc_monitor.log"

# Container Filter
containers:
  ignore_stopped: true     # Skip stopped containers
  ignore_templates: true   # Skip template containers

# Performance
performance:
  batch_size: 10           # Containers per batch
  timeout: 5               # Timeout per container

Monitor Options

OptionTypeDefaultDescription
metrics.output_filestring/var/log/lxc_metrics.jsonMetrics output path
metrics.max_entriesinteger1000Maximum entries to keep
metrics.collection_intervalinteger10Collection interval (seconds)
containers.ignore_stoppedbooleantrueSkip stopped containers
containers.ignore_templatesbooleantrueSkip template containers
performance.batch_sizeinteger10Containers per batch
performance.timeoutinteger5Timeout per container

Configuration Validation

The model validates configuration on startup. Common validation rules:

RuleError Message
min_cpu_cores > max_cpu_cores"min_cpu_cores cannot be greater than max_cpu_cores"
min_ram_mb > max_ram_mb"min_ram_mb cannot be greater than max_ram_mb"
cpu_scale_down_threshold >= cpu_scale_up_threshold"cpu_scale_down_threshold must be less than cpu_scale_up_threshold"
Threshold outside 0-100"threshold must be between 0 and 100"

Validate Configuration Syntax

bash
python3 -c "import yaml; yaml.safe_load(open('/etc/lxc_autoscale_ml/lxc_autoscale_ml.yaml'))"

If there's no output, the YAML is valid.

Example Configurations

Conservative Scaling

Slower, more cautious scaling for production:

yaml
scaling:
  cpu_scale_up_threshold: 85
  cpu_scale_down_threshold: 20
  ram_scale_up_threshold: 90
  ram_scale_down_threshold: 30
  min_confidence: 80

sleep_interval: 120

Aggressive Scaling

Faster response for development environments:

yaml
scaling:
  cpu_scale_up_threshold: 60
  cpu_scale_down_threshold: 40
  ram_scale_up_threshold: 70
  ram_scale_down_threshold: 50
  min_confidence: 60

sleep_interval: 30

Large Deployment

Optimized for 60+ containers:

yaml
api:
  max_concurrent: 15
  timeout: 10

circuit_breaker:
  failure_threshold: 3
  timeout_seconds: 600

sleep_interval: 120

Applying Configuration Changes

After modifying configuration files, restart the relevant service:

bash
# API changes
systemctl restart lxc_autoscale_api

# Model changes
systemctl restart lxc_autoscale_ml

# Monitor changes
systemctl restart lxc_monitor

Released under the MIT License.