Skip to main content

A simple yet efficient scaling agent for Python apps on Heroku

Project description

Dynoscale Agent

Simple yet efficient scaling agent for Python apps on Heroku

📖 Usage

  1. Add dynoscale to your app on Heroku: heroku addons:create dscale
  2. Install dynoscale: python -m pip install dynoscale
    1. Add dynoscale to your app, you can either wrap your app or if you use Gunicorn, you can also just use one of its hooks (pre_request):
      1. If you want to wrap you app (let's look at Flask example):
      from flask import Flask
      
      app = Flask(__name__)
      
      @app.route("/")
      def index():
          return "Hello from Flask!"
      
      if __name__ == "__main__":
          app.run(host='127.0.0.1', port=3000, debug=True)
      
      then just wrap your WSGI app like this
      from flask import Flask
      # FIRST, IMPORT DYNOSCALE
      from dynoscale.wsgi import DynoscaleWsgiApp
      
      app = Flask(__name__)
      
      @app.route("/")
      def index():
          return "Hello from Flask!"
      
      if __name__ == "__main__":
          # THE CHANGE BELOW IS ALL YOU NEED TO DO
          app.wsgi_app = DynoscaleWsgiApp(app.wsgi_app)
          # YUP, WE KNOW, CAN'T GET SIMPLER THAN THAT :)
          app.run(host='127.0.0.1', port=3000, debug=True)
      
    2. Or, if you'd prefer to use the hook, then change your gunicorn.conf.py accordingly instead:
      # This one line will do it for you:
      from dynoscale.hooks.gunicorn import pre_request  # noqa # pylint: disable=unused-import
      
      If you already use the pre_request hook, alias ours and call it manually:
      # Alias the import...
      from dynoscale.hooks.gunicorn import pre_request as hook
      
      # ...and remember to call ours first!
      def pre_request(worker, req):
         hook(worker, req)
         # ...do your own thing...
      
  3. Profit! Literally, this will save you money! 💰💰💰 😏

ℹ️ Info

You should consider the dynoscale.wsgi.DynoscaleWsgiApp(wsgi_app) and dynoscale.hooks.gunicorn.pre_request(worker, req) the only two bits of public interface.

🤯 Examples

Feel free to check out ./examples, yes, we do have examples in the repository :)

👩‍💻 Contributing

Install development requirements by running noglob pip install -e .[test] if you use ZSH, or pip install -e .[test] if you're stuck with Bash.

You can run pytest from terminal: pytest

You can run flake8 from terminal: flake8 ./src

Download files

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

Source Distribution

dynoscale-1.1.2.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

dynoscale-1.1.2-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file dynoscale-1.1.2.tar.gz.

File metadata

  • Download URL: dynoscale-1.1.2.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.2.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.13

File hashes

Hashes for dynoscale-1.1.2.tar.gz
Algorithm Hash digest
SHA256 259393d1ed6722fbd9ed6763dd594422c0ae2454cb277604d25780737902e126
MD5 6f8e3b08280c006be446edb1b68b210c
BLAKE2b-256 4a0f44ba84e3a8ff61b254c09f15bd47e535ea1c96cba2837ca94f6bd435833a

See more details on using hashes here.

File details

Details for the file dynoscale-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: dynoscale-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.2.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.13

File hashes

Hashes for dynoscale-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f36335b77e971b60ca22c0f899f12f1003d19b1ec87c524c7516f0798817c07e
MD5 097c1dac0dee15ef7150a86840073433
BLAKE2b-256 340adabde48aeb067efcd6cde0b9604ed4bb00ae128d2b7857cf955282f3c6f7

See more details on using hashes here.

Supported by

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