Skip to main content

A package for managing Heroku dynos with autoscaling capabilities

Project description

Heroku Manager

A Python package for managing Heroku dynos with autoscaling capabilities.

Features

  • Automatic scaling of Heroku dynos based on memory usage and load
  • Monitoring of dyno health and performance
  • Automatic restart of unresponsive dynos
  • Integration with Django for caching and configuration

Installation

pip install heroku-manager

Usage

from heroku_manager import HerokuManager

# Get the autoscaler instance
autoscaler = HerokuManager.get_autoscaler()

# Start continuous autoscaling
autoscaler.start_continuous_autoscale()

# Manual scaling operations
if autoscaler.requires_upscale:
    autoscaler.upscale_formation_to_next_level()
elif autoscaler.allow_downscale:
    autoscaler.downscale_formation_to_original_size()

# Stop autoscaling
autoscaler.stop_continuous_autoscale()

Configuration

The package requires the following environment variables:

  • HEROKU_API_KEY: Your Heroku API key
  • HEROKU_APP_NAME: The name of your Heroku app
  • DYNO: The name of the current dyno (automatically set by Heroku)

Django Settings

When used with Django, the following settings are available:

  • DYNO_CONTINUOS_AUTOSCALE_ENABLED: Enable continuous autoscaling
  • DYNO_AUTOSCALE_INTERVAL: Interval between autoscale checks (in seconds)
  • DYNO_TIME_BETWEEN_SCALES: Minimum time between scaling operations (in seconds)
  • DYNO_MIN_UPSCALE_DURATION: Minimum duration to keep a dyno upscaled (in seconds)
  • DYNO_DOWNSCALE_CHECK_INTERVAL: Interval for checking if a dyno can be downscaled (in seconds)
  • DYNO_ZOMBIE_THRESHOLD: Time threshold for considering a dyno as unresponsive (in seconds)
  • DYNO_LOG_THREADS_USED: Whether to log the number of threads used
  • DYNO_LOGS_CACHE_DURATION: Duration to cache dyno logs (in seconds)
  • DYNO_ERRORS_TIMEOUT_DURATION: Duration to cache error information (in seconds)
  • DYNO_GENERAL_CACHE_DURATION: General cache duration (in seconds)
  • DYNO_TIME_BETWEEN_RESTARTS: Minimum time between dyno restarts (in seconds)
  • DYNO_AUTOSCALE_ENABLED_FOR_BEATWORKER: Whether to enable autoscaling for beat workers
  • UPSCALE_PERCENTAGE_HIGH_MEM_USE: Memory usage percentage threshold for upscaling
  • DOWNSCALE_PERCENTAGE_HIGH_MEM_USE: Memory usage percentage threshold for downscaling
  • HIGH_MEM_USE_MB: High memory usage threshold in MB

Project details


Download files

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

Source Distribution

heroku_manager-0.1.2.tar.gz (11.7 kB view details)

Uploaded Source

File details

Details for the file heroku_manager-0.1.2.tar.gz.

File metadata

  • Download URL: heroku_manager-0.1.2.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for heroku_manager-0.1.2.tar.gz
Algorithm Hash digest
SHA256 eb8bfca0d3daa27b8983675b0de070a533daa311fd149096f562ab8f9130029b
MD5 7b01dff18d9dd1e52e026fbbfe60af4d
BLAKE2b-256 c038e25b062ba4469c869bd869d00816e5aaaa7f69c67147d4de362aea315826

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