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
- Add dynoscale to your app on Heroku:
heroku addons:create dscale
- Install dynoscale:
python -m pip install dynoscale
- 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``):
- 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 thisfrom 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)
- 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 thepre_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...
- 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``):
- 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
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
dynoscale-1.1.0.tar.gz
(14.4 kB
view details)
Built Distribution
dynoscale-1.1.0-py3-none-any.whl
(16.6 kB
view details)
File details
Details for the file dynoscale-1.1.0.tar.gz
.
File metadata
- Download URL: dynoscale-1.1.0.tar.gz
- Upload date:
- Size: 14.4 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ab1c979526a160c3eb7fcf7f766fd5376ddea0ae949c01539a758ba9752b52a |
|
MD5 | c1ca53666e00e0fdfb7c0afdad5b08ca |
|
BLAKE2b-256 | f7f527810d2e0e4894231d81ed5f0f4d1c764dd6737b4f64b160f395be2d5a44 |
File details
Details for the file dynoscale-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: dynoscale-1.1.0-py3-none-any.whl
- Upload date:
- Size: 16.6 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11ab7a26f7a71d169b6ff6647fd854b6f3bdfa184f2ef8b4e2fd765921ced726 |
|
MD5 | 3d8396479098a3db99174d3f916275ea |
|
BLAKE2b-256 | 22e7e5ebd7ee0b0b46b930a48c40dbc38de070f1a3cebb46788d7be8d399f436 |