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.pyaccordingly 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_requesthook, 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.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dynoscale-1.0.0.tar.gz.
File metadata
- Download URL: dynoscale-1.0.0.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4362b044bd3373771703dc982f844945c359756c5ce20e8ee360c6a8a6ab2551
|
|
| MD5 |
5268951996ca7a05916b7b6e8766fa9f
|
|
| BLAKE2b-256 |
1ad6d20c457734059bbdad3322ba789fdd5146c54287a6e6246f3fe100b90c36
|
File details
Details for the file dynoscale-1.0.0-py3-none-any.whl.
File metadata
- Download URL: dynoscale-1.0.0-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18808eb8461bdacc466e57268d1446e19304513427a8a95464c3c20f5ffb1085
|
|
| MD5 |
d3f82b4049f732291825de8e531c40c7
|
|
| BLAKE2b-256 |
a1baa1a575b7bd1dbf1b67461aa18d6597285677185a51ddf12ca3c110e37fa6
|