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.1.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

dynoscale-1.1.1-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dynoscale-1.1.1.tar.gz
  • Upload date:
  • Size: 14.5 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.1.tar.gz
Algorithm Hash digest
SHA256 6af6a24042b3c0d0b5e3b9f4d7de708eb022501ef5562fcfd2ee6d5963294b0e
MD5 a33fffc196e79ae27fedc5cbc004f576
BLAKE2b-256 1d15d6f80f1ca50baa808c305f44e2153442184303b50075c2e80aee678f9f8d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dynoscale-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.7 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bdba8edcb32e69c71c156fd3bd5a27310dcf22b80599ed9f3a8164311788d20b
MD5 fac1709056bdf1729151eee366ebb6a4
BLAKE2b-256 da844e92d2ce30f4bb5ac6d68bc75296013ae7601e15e39ed2cf2f99fb2c7a1e

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