Skip to content

Getting Started

Prerequisites

  • Proxmox VE 7.x or 8.x (tested with 8.3.3)
  • Python 3.9+
  • Root access to the Proxmox host
  • LXC containers already created and configured

Installation

Run the install script on the Proxmox host:

bash
curl -sSL https://raw.githubusercontent.com/fabriziosalmi/proxmox-lxc-autoscale/main/install.sh | bash

Verify the service is running:

bash
systemctl status lxc_autoscale.service

Example output:

root@proxmox:~# systemctl status lxc_autoscale.service
● lxc_autoscale.service - LXC AutoScale Daemon
     Loaded: loaded (/etc/systemd/system/lxc_autoscale.service; enabled)
     Active: active (running) since Mon 2024-08-19 01:38:07 CEST; 7s ago
   Main PID: 40462 (python3)
     Memory: 9.1M
     CGroup: /system.slice/lxc_autoscale.service
             └─40462 /usr/bin/python3 /usr/local/bin/lxc_autoscale/lxc_autoscale.py

How it works

Each polling cycle (default: 300 seconds):

  1. Collect — CPU and memory usage is read for each running container via host-side cgroup accounting.
  2. Evaluate — Usage is compared against the container's tier thresholds (or global defaults).
  3. Scale — If usage exceeds the upper threshold, cores/memory are added. If below the lower threshold, they are reduced.
  4. Pin — If cpu_pinning is configured, the container is pinned to the specified CPU cores.
  5. Log — All scaling events are logged (plain text and JSON) and optionally sent as notifications.

Resource measurement

CPU and memory usage are both read from host-side cgroup accounting (cgroup v2 with v1 fallback). This reads the kernel's own resource tracking directly from the Proxmox host without executing commands inside containers.

Benefits:

  • Accurate measurements matching the Proxmox web UI
  • No dependency on LXCFS
  • Minimal overhead (file reads instead of pct exec)
  • Correct results on low-core hosts with many containers
  • First measurement cycle is non-blocking (no 2-second sleep)

If cgroup accounting is unavailable, the daemon falls back to /proc/stat for CPU (requires LXCFS) and /proc/meminfo via pct exec for memory.

Backends

LXC AutoScale supports two backends for communicating with Proxmox:

BackendConfig valueHow it worksRequirements
CLI (default)backend: cliExecutes pct commands locally or via SSHRoot access (local) or SSH credentials (remote)
REST APIbackend: apiCalls the Proxmox REST API via HTTPpip install proxmoxer, API token

The CLI backend is the default and requires no additional dependencies. The REST API backend avoids shell access entirely and uses scoped API tokens, which is preferable for security-sensitive deployments.

See Configuration for backend setup details.

Next steps

Released under the MIT License.