Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
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