-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async #8
base: master
Are you sure you want to change the base?
Async #8
Conversation
@yohanboniface what are your thoughts on dockerised deployment. I've been using nginx reverse proxy to load-balance to multiple dockerised containers ( |
Not a Docker fanboy myself, I think Nginx + gunicorn and multiple workers should scale well. |
It is mainly handy for easing deployment without needing to reproduce a python environment & packages. |
Attempt at going async.
I've made the choice of a very low level approach to pull in as little as possible code and make it easier to optimize. Utilery does only one thing after all: take a (simple) URL and return a response. No form handling nor request body parsing, no cookie, no need to be generic…
Basically, async does not prove to be faster, but the code simplification and the use of httptools and asyncpg may worth it.
Bench: https://gist.github.com/yohanboniface/d168050ee7db382341c8724cbd941cac
We can see a very small boost (on my laptop).
Async or not, at the end, the real way to scale the tile server is:
Async makes it easier to server more requests on a single process, but this can be achieved by Gunicorn/uwsgi + nginx much better in any cases. And this is the cons of this PR: it's harder to deploy with Nginx and uwsgi. This is why I've made a Gunicorn worker.
I'll look at serving with uwsgi in the future (needs a custom uwsgi compilation for now).
How to run:
Debug:
Bench production:
Tests are passing, but coverage have decreased due to replacing Werkzeug by httptools and asyncio.create_server, which needs dedicated tests. I'll add them.
Also I'll do more benchs for code optimization (having persistent views for example).
cc @Shongololo @magopian
cf #5