Releases: Mjolnir-Software/dynoscale-python
Releases · Mjolnir-Software/dynoscale-python
v1.2.2
v1.2.1
v1.2.0
1.2.0 [2023-01-08]
- dropping support for Python 3.7, 3.8, 3.9
- adding support for Gunicorn with Uvicorn workers, use dynoscale.uvicorn.DynoscaleUnicornWorker
...
📖 Complete ASGI example
- Add dynoscale to your app on Heroku:
heroku addons:create dscale - Prepare your amazing webapp, we'll use Starlette served by Gunicorn with Uvicorn workers:
... add Gunicorn config:
# web.py import datetime from starlette.applications import Starlette from starlette.responses import Response from starlette.routing import Route async def home(_): return Response( "Hello from 🌟 Starlette 🌟 served by Gunicorn using Uvicorn workers and scaled by Dynoscale!\n" f"It's {datetime.datetime.now()} right now.", media_type='text/plain' ) app = Starlette(debug=True, routes=[Route('/', endpoint=home, methods=['GET'])])
# gunicorn.conf.py import os # ENV vars PORT = int(os.getenv('PORT', '3000')) WEB_CONCURRENCY = int(os.getenv('WEB_CONCURRENCY', '10')) # Gunicorn config wsgi_app = "web:app" # ┌---------- THIS HERE IS ALL OF DYNOSCALE SETUP ----------┐ # | # worker_class = 'uvicorn.workers.UvicornWorker' | worker_class = 'dynoscale.uvicorn.DynoscaleUvicornWorker' # | # └---------------------------------------------------------┘ bind = f"0.0.0.0:{PORT}" preload_app = True workers = WEB_CONCURRENCY max_requests = 1000 max_requests_jitter = 50 accesslog = '-' loglevel = 'debug'
- Install all the dependencies:
python -m pip install "uvicorn[standard]" gunicorn dynoscale
- Start it up with:
DYNO=web.1 DYNOSCALE_DEV_MODE=true DYNOSCALE_URL=https://some_request_bin_or_some_such.com gunicorn
- On Heroku, DYNO and DYNOSCALE_URL will be set for you, you should only have
web: gunicornin your procfile. - In this example we start Dynoscale in dev mode to simulate random queue times, don't do this on Heroku!
- On Heroku, DYNO and DYNOSCALE_URL will be set for you, you should only have
- That's it you're done, now Profit! Literally, this will save you money! 💰💰💰 😏
...
v1.1.3
- Added support for ASGI through DynoscaleAsgiApp class
- Added options to control DS repository storage location with environment variables
.
..
...
If you have an ASGI app (ex.: Starlette, Responder, FastAPI, Sanic, Django, Guillotina, ...) pass your ASGI app
into DynoscaleASGIApp:
# `web.py` - Starlette Example
import os
from starlette.applications import Starlette
from starlette.responses import Response
from starlette.routing import Route
from dynoscale.asgi import DynoscaleAsgiApp
async def home(_):
return Response("Hello from Starlette, scaled by Dynoscale!", media_type='text/plain')
app = DynoscaleAsgiApp(Starlette(debug=True, routes=[Route('/', endpoint=home, methods=['GET'])]))
if __name__ == "__main__":
import uvicorn
uvicorn.run('web:app', host='0.0.0.0', port=int(os.getenv('PORT', '8000')), log_level="info")...
..
.
... more info in README.md