Skip to main content

Python SDK for QScaler - Kubernetes-native queue worker autoscaler

Project description

QScaler-SDK

Python SDK for integration with QScaler, a Kubernetes-native queue worker autoscaler.

OverviewOverview

QScaler-SDK enables efficient scaling of queue workers in a Kubernetes environment. It works by monitoring changes in the QWORKER_NAME Custom Resource Definition (CRD) managed by the QScaler controller.

Key Features

  • Automatically detects changes in desired replica counts or pod specifications.
  • Gracefully shuts down when necessary to ensure smooth scaling and resource optimization.
  • Continuously loops to process tasks unless a change is detected.

How It Works

  1. Monitor Changes: The worker watches the QWORKER_NAME CRD for updates.
  2. Trigger Actions:
    • If a change in the desired replica count or pod specification hash is detected:
      • The worker removes its owner reference.
      • Initiates a graceful shutdown process.
    • If no changes are detected, the worker:
      • Continues running indefinitely.
      • Periodically checks for differences at intervals defined by PULLING_INTERVAL.
  3. Task Processing: During each loop, the worker processes tasks unless a termination condition is met.

Setup

To use QScaler-SDK, configure the following environment variables:

Environment Variables

Variable Description
QWORKER_NAME Name of the QWorker CRD to monitor.
PULLING_INTERVAL Interval (in seconds) for checking the QWorker CRD status when no tasks are running.
POD_SPEC_HASH Hash of the current pod specification. Used to detect changes in the CRD and trigger shutdown.
HOSTNAME Name of the pod, automatically set by Kubernetes.

Example

A complete example is provided in the example folder, including the following files:

worker.py

qworker.yaml

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qscaler-0.0.1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file qscaler-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: qscaler-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.1 Linux/6.11.0-1015-azure

File hashes

Hashes for qscaler-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 64cdf2bb8a852953753aef701399b958b221527278e741d2b443076f60c0156c
MD5 743e7e9e4cac845647a64fd4771db8fc
BLAKE2b-256 5d4ec0b4f252aef376d506ec063ed89d663b95f57170f3affb1fe0b365488d9e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page