Skip to main content

A Python app server based on envoy

Project description

pyvoy

License CI codecov PyPI version

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.

Features

  • ASGI applications
  • WSGI applications with worker threads
  • A complete, battle-tested HTTP stack - it's just Envoy
    • Includes full HTTP protocol support, with HTTP/2 trailers and HTTP/3
  • Any Envoy configuration features such as load shedding can be integrated as normal

Limitations

  • Platforms limited to those supported by Envoy, which generally means glibc-based Linux on amd64/arm64 or MacOS on arm64
  • 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 are prevented by Envoy itself
    • The full URL path, including query string, must be ASCII percent-encoded

Installation

pyvoy is published as a wheel that includes both the dynamic module and Envoy itself. You can use it in the same way as any other app server.

uv add pyvoy # or pip install

Running

pyvoy includes a CLI which supports standard options for HTTP servers. If just passing a module:attr name to point to an application, it will be served on plaintext on port 8000.

uv run pyvoy my.module:app

(if the application is named exactly app, :app can be omitted)

To see a full list of options:

uv run pyvoy -h

Docker

[!NOTE] This is an initial pattern and we will iterate on it, notably it will be good to remove the python version from the environment variables.

For production deployments to containers, we recommend running Envoy directly without the pyvoy CLI to avoid potential issues with subprocess spawning. The pyvoy CLI simply spawns Envoy with an appropriate YAML config and environment variables for loading the dynamic module. You can see the example Dockerfile for how to set up the config and environment for running Envoy directly.

Note that the pyvoy CLI with --print-envoy-config is run within the Dockerfile to easily set up the config. This is convenient for simple cases and should run well for normal deployments. But for experienced Envoy users that want to configure other aspects of Envoy, we also recommend managing the Envoy config in your codebase and adding it to the container - you can then tweak any and all Envoy parameters to meet your needs.

Benchmarks

We have some preliminary benchmarks just to understand how the approach works specifically for HTTP/2. The main goal is to see if pyvoy runs in the same ballpark as other servers.

A single example from CI for a 10ms service with 10K response size shows:

Running benchmark for pyvoy with protocol=h2 sleep=10ms response_size=10000

Requests      [total, rate, throughput]         13460, 2691.78, 2686.15
Duration      [total, attack, wait]             5.011s, 5s, 10.489ms
Latencies     [min, mean, 50, 90, 95, 99, max]  9.546ms, 11.141ms, 11.066ms, 11.943ms, 12.246ms, 12.997ms, 16.798ms
Bytes In      [total, mean]                     134600000, 10000.00
Bytes Out     [total, mean]                     0, 0.00
Success       [ratio]                           100.00%
Status Codes  [code:count]                      200:13460
Error Set:


Running benchmark for granian with protocol=h2 sleep=10ms response_size=10000

Requests      [total, rate, throughput]         13489, 2697.08, 2691.47
Duration      [total, attack, wait]             5.012s, 5.001s, 10.423ms
Latencies     [min, mean, 50, 90, 95, 99, max]  9.253ms, 11.111ms, 11.038ms, 11.883ms, 12.172ms, 12.946ms, 16.373ms
Bytes In      [total, mean]                     134890000, 10000.00
Bytes Out     [total, mean]                     0, 0.00
Success       [ratio]                           100.00%
Status Codes  [code:count]                      200:13489
Error Set:

Running benchmark for hypercorn with protocol=h2 sleep=10ms response_size=10000

Requests      [total, rate, throughput]         1002, 183.30, 177.42
Duration      [total, attack, wait]             5.479s, 5.466s, 12.183ms
Latencies     [min, mean, 50, 90, 95, 99, max]  11.43ms, 163.65ms, 13.497ms, 16.099ms, 17.629ms, 5.019s, 5.023s
Bytes In      [total, mean]                     9720000, 9700.60
Bytes Out     [total, mean]                     0, 0.00
Success       [ratio]                           97.01%
Status Codes  [code:count]                      0:30  200:972
Error Set:
Get "http://localhost:8000/controlled": http2: server sent GOAWAY and closed the connection; LastStreamID=2001, ErrCode=NO_ERROR, debug=""

We see that hypercorn seems to not perform well with HTTP/2, with errors and resulting poor performance numbers. We will focus comparisons on granian.

Performance seems to be mostly the same between pyvoy and granian within the range of noise for a fast but still useful in real-world service.

We can try to isolate more performance of the app server itself with a less realistic service with no delay or response.

 Running benchmark for pyvoy with protocol=h2 sleep=0ms response_size=0

Requests      [total, rate, throughput]         104043, 20808.94, 20805.37
Duration      [total, attack, wait]             5.001s, 5s, 856.185µs
Latencies     [min, mean, 50, 90, 95, 99, max]  344.742µs, 1.327ms, 1.294ms, 1.736ms, 1.905ms, 2.271ms, 3.965ms
Bytes In      [total, mean]                     0, 0.00
Bytes Out     [total, mean]                     0, 0.00
Success       [ratio]                           100.00%
Status Codes  [code:count]                      200:104043
Error Set:

Running benchmark for granian with protocol=h2 sleep=0ms response_size=0

Requests      [total, rate, throughput]         96513, 19302.87, 19298.03
Duration      [total, attack, wait]             5.001s, 5s, 1.254ms
Latencies     [min, mean, 50, 90, 95, 99, max]  304.289µs, 1.501ms, 1.506ms, 1.827ms, 1.931ms, 2.2ms, 3.776ms
Bytes In      [total, mean]                     0, 0.00
Bytes Out     [total, mean]                     0, 0.00
Success       [ratio]                           100.00%
Status Codes  [code:count]                      200:96513
Error Set:

We again see very similar performance likely within the range of noise.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyvoy-0.1.1-cp314-cp314-manylinux_2_31_x86_64.whl (30.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.31+ x86-64

pyvoy-0.1.1-cp314-cp314-manylinux_2_31_aarch64.whl (28.5 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.31+ ARM64

pyvoy-0.1.1-cp314-cp314-macosx_15_0_arm64.whl (32.6 MB view details)

Uploaded CPython 3.14macOS 15.0+ ARM64

pyvoy-0.1.1-cp313-cp313-manylinux_2_31_x86_64.whl (30.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.31+ x86-64

pyvoy-0.1.1-cp313-cp313-manylinux_2_31_aarch64.whl (28.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.31+ ARM64

pyvoy-0.1.1-cp313-cp313-macosx_15_0_arm64.whl (32.6 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

pyvoy-0.1.1-cp312-cp312-manylinux_2_31_x86_64.whl (30.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.31+ x86-64

pyvoy-0.1.1-cp312-cp312-manylinux_2_31_aarch64.whl (28.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.31+ ARM64

pyvoy-0.1.1-cp312-cp312-macosx_15_0_arm64.whl (32.6 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

pyvoy-0.1.1-cp311-cp311-manylinux_2_31_x86_64.whl (30.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.31+ x86-64

pyvoy-0.1.1-cp311-cp311-manylinux_2_31_aarch64.whl (28.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.31+ ARM64

pyvoy-0.1.1-cp311-cp311-macosx_15_0_arm64.whl (32.6 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

pyvoy-0.1.1-cp310-cp310-manylinux_2_31_x86_64.whl (30.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.31+ x86-64

pyvoy-0.1.1-cp310-cp310-manylinux_2_31_aarch64.whl (28.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.31+ ARM64

pyvoy-0.1.1-cp310-cp310-macosx_15_0_arm64.whl (32.6 MB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

File details

Details for the file pyvoy-0.1.1-cp314-cp314-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.1-cp314-cp314-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 d23b0c0067123b623ca50af1e7d10ebf770bf794d3552c1b329e299cd375cc27
MD5 d149a78ddc6360a0ceb48a71a99ae72b
BLAKE2b-256 f48f1873c4323f94ff88edc80e1a15f633168926e95a407f075da14afc835c77

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.1-cp314-cp314-manylinux_2_31_x86_64.whl:

Publisher: release.yaml on curioswitch/pyvoy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvoy-0.1.1-cp314-cp314-manylinux_2_31_aarch64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.1-cp314-cp314-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 f4309ef1b8add370f6c4762033a32ad18baffbba913a448885af6b712049161c
MD5 bcfa1d8bf88f7bec517b2000216f25c1
BLAKE2b-256 c2cf0cee6a14ecfc1751cc1569e5f3471cde2688b95ee2ee5dd1e86a58aa8262

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.1-cp314-cp314-manylinux_2_31_aarch64.whl:

Publisher: release.yaml on curioswitch/pyvoy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvoy-0.1.1-cp314-cp314-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.1-cp314-cp314-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 768af0d632edbafc8cf200541f3c805ac4604c74b01cb7c367698684b9850b71
MD5 d2f3491ca67ae56638bac796975a41f5
BLAKE2b-256 0392b44d292d55d26512cc7af2e403b0615bd55837709ed30bca5e6f266ca5c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.1-cp314-cp314-macosx_15_0_arm64.whl:

Publisher: release.yaml on curioswitch/pyvoy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvoy-0.1.1-cp313-cp313-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.1-cp313-cp313-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 316e26e732e4718b9345c9e27914ffb0a72ea25a894bcff9c1690a4b244b905a
MD5 c97723e1bcb9dfc8207c9743f62d0a55
BLAKE2b-256 77618bcfb263f703f02f2698d6b50c53e63d9e87f65beae1ad21c918a16adf82

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.1-cp313-cp313-manylinux_2_31_x86_64.whl:

Publisher: release.yaml on curioswitch/pyvoy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvoy-0.1.1-cp313-cp313-manylinux_2_31_aarch64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.1-cp313-cp313-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 71a42e9903204a9b626ad5ff9baabc556673092d299c26508f9bb6707f1cf4d0
MD5 9c50e002803cdfacba77d44ce1839240
BLAKE2b-256 5260f93e7fdaf31a81ddc5a7d586c6e5fd17315e7392b2affce352282dfa69e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.1-cp313-cp313-manylinux_2_31_aarch64.whl:

Publisher: release.yaml on curioswitch/pyvoy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvoy-0.1.1-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.1-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 846a5cb4b5fb23d358d6e4694c358046a73966e1df5d16bddd5304a034e23ced
MD5 edd4bc5c8ad6dcf44dd8ec34586198a1
BLAKE2b-256 079a2e5a0d02b1b1d53fc8e1abbc43890145017503b71af9423048f298139d3f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.1-cp313-cp313-macosx_15_0_arm64.whl:

Publisher: release.yaml on curioswitch/pyvoy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvoy-0.1.1-cp312-cp312-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.1-cp312-cp312-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 ea4705a57fb54b07a73fd061094fcba20c56c644e67789d82c939c72d1f50a62
MD5 85a4db5019875e4865be465a55993d9a
BLAKE2b-256 eb175562985594785bf63e3a14e51665ce24831e8a1b32791cd9edc8bb928926

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.1-cp312-cp312-manylinux_2_31_x86_64.whl:

Publisher: release.yaml on curioswitch/pyvoy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvoy-0.1.1-cp312-cp312-manylinux_2_31_aarch64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.1-cp312-cp312-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 31950bc4e33f1918f57a88b6c42b99cac88ac098699b9c9384a24fdf44621668
MD5 09ebc583e0d9a93d9535db5c0162c1be
BLAKE2b-256 e7ab2a954859148fb09088af111947135d42922473dafc909c512a96f6b89896

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.1-cp312-cp312-manylinux_2_31_aarch64.whl:

Publisher: release.yaml on curioswitch/pyvoy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvoy-0.1.1-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.1-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 6e714b70ef9c6e5375a3bfd0fac4bba4235df08ac90654ec5ba8a29faee629c6
MD5 3b85498c3b252273662d146b6bf6641a
BLAKE2b-256 ccb98c0a4ecea4e8f92718df413f8dac8c33b164b4128983294168176fbf7078

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.1-cp312-cp312-macosx_15_0_arm64.whl:

Publisher: release.yaml on curioswitch/pyvoy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvoy-0.1.1-cp311-cp311-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.1-cp311-cp311-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 7e6bc1a00af4e3b8f6488f80dfdbe1ffae6fbf36d10c2f976d8422e10ebbd269
MD5 fbdd87cda772a67429aa3eb7922f4481
BLAKE2b-256 4beae586a7363b22bbdacca6ef45ae5f790fe1b80ef9845efbf9f6cdc39617e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.1-cp311-cp311-manylinux_2_31_x86_64.whl:

Publisher: release.yaml on curioswitch/pyvoy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvoy-0.1.1-cp311-cp311-manylinux_2_31_aarch64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.1-cp311-cp311-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 797fc8be156911b7c6f67c144907ac861caf8c92b3163529f0a4769fae0d1fc8
MD5 15fba282d9b189649a0e951a8869ccad
BLAKE2b-256 dbecf1fdc9a0653752eaa6579ad94a92f1681c0a806b3b253bf2d670856b6bd7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.1-cp311-cp311-manylinux_2_31_aarch64.whl:

Publisher: release.yaml on curioswitch/pyvoy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvoy-0.1.1-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.1-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 bd4257f36aed121c6bae661e98d8c0cc36de17ddfe768885d1a317170c34127a
MD5 323af17f22b3e261bed5345abced0cb9
BLAKE2b-256 d89230fb684bebaabb2562358dc5ba5f5446a5c0fc3f4ea30192694b7a18847f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.1-cp311-cp311-macosx_15_0_arm64.whl:

Publisher: release.yaml on curioswitch/pyvoy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvoy-0.1.1-cp310-cp310-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.1-cp310-cp310-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 f2c76d8cf5b82467da25922acbab4185ae9dcd9f90636cd05ec8c8d2ed8e30dd
MD5 eded10c1512f49e72b2483ff540cf09e
BLAKE2b-256 f41e33b305a187ca7d8540c16d6f028133bb7f88106c14e10b445d4b96d67eae

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.1-cp310-cp310-manylinux_2_31_x86_64.whl:

Publisher: release.yaml on curioswitch/pyvoy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvoy-0.1.1-cp310-cp310-manylinux_2_31_aarch64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.1-cp310-cp310-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 ac1ef45c47b821b161d39d69fd9940859d2bde332ef7b346a02d49e235aadf83
MD5 5dc8b0502bb7b5b8b9562a0722a28f8e
BLAKE2b-256 31a142cfc60d6493675a7c8892130ef168d68b0384848ad99f1045834c0877d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.1-cp310-cp310-manylinux_2_31_aarch64.whl:

Publisher: release.yaml on curioswitch/pyvoy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvoy-0.1.1-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.1-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 bb49d21db16e4e0f8891a98fea5cb0265994e1fed1d969bb66af20bf92613536
MD5 d0b81b68040a48f2d0ec83c9b8b3f21b
BLAKE2b-256 1eee29423d825b9cdbf53cb3d24e9215015d9813add7d428f4cb6c2a5938bec5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.1-cp310-cp310-macosx_15_0_arm64.whl:

Publisher: release.yaml on curioswitch/pyvoy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page