
A Python application server in Envoy
pyvoy is a Python application server implemented in Envoy. It is based on Envoy dynamic modules, embedding a Python interpreter into a module that can be loaded by a stock Envoy binary.
Python servers have generally lagged behind on support for modern HTTP. pyvoy utilizies the battle-hardened Envoy to bring you all features of HTTP/2 and 3, with great performance and stability.
Features
- ASGI and WSGI applications with worker threads
- A complete, battle-tested HTTP stack - it's just Envoy
- Any Envoy configuration features can be integrated as normal
- Auto-restart on file change and IDE debugging for development
Limitations
- Platforms limited to those supported by Envoy, which generally means glibc-based Linux on amd64/arm64, MacOS on arm64, and unofficial support for Windows on amd64
- No support for multiple worker processes. It is recommended to scale up with a higher-level orchestrator instead and use a health endpoint wired to RSS for automatic restarts if needed
- Certain non-compliant requests like non-ascii query strings are prevented by Envoy itself
Quickstart
pyvoy is available on PyPI so can be installed using your favorite package manager.
This will also include the Envoy binary itself - there are no other steps to get running.
Given a simple ASGI application:
async def app(scope, receive, send):
await send({
'type': 'http.response.start',
'status': 200,
'headers': [
(b'content-type', b'text/plain'),
(b'content-length', b'13'),
],
})
await send({
'type': 'http.response.body',
'body': b'Hello, world!',
'more_body': False,
})
Pass it to pyvoy to run.
Using cURL, you can try out a request.
Flask works fine too, just make sure to pass --interface=wsgi when running pyvoy.
For a list of all settings
or see the documentation for settings.
Why pyvoy?
pyvoy was created out of a desire to bring HTTP/2 trailers to Python application servers to allow using the gRPC protocol with standard applications. While developing it, we have found it to be a very fast, stable server for any workload - notably, it is the only server known to pass all of the conformance tests for connect-python.
What pyvoy isn't is a traditional Python application - we execute Envoy itself, which then loads the Python interpreter to start the application server. This means certain features like listening on sockets in forked processes cannot be implemented no matter how hard we try as it is in the domain of Envoy, which ensures they are handled efficiently and stably. It doesn't mean we miss out on features like IDE debugging though, which we do support. We also make sure to support common platforms, Linux, macOS, and Windows, though we cannot support more than that due to lack of support in Envoy.
ASGI and WSGI make it easy to switch servers to try - hopefully you can give it a try and see if you like it.