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.

Development

We use poe for running development tasks. For a list of tasks, you can run

uv run poe -h

During development, the most common commands will be

uv run poe test # Run unit tests
uv run poe format # Apply possible formatting
uv run poe check # Run all checks. If this passes, CI should pass
uv run poe build # Only build pyvoy. Needed if running tests from IDE

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.2-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.2-cp314-cp314-manylinux_2_31_aarch64.whl (28.5 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.31+ ARM64

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

Uploaded CPython 3.14macOS 15.0+ ARM64

pyvoy-0.1.2-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.2-cp313-cp313-manylinux_2_31_aarch64.whl (28.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.31+ ARM64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

pyvoy-0.1.2-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.2-cp312-cp312-manylinux_2_31_aarch64.whl (28.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.31+ ARM64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

pyvoy-0.1.2-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.2-cp311-cp311-manylinux_2_31_aarch64.whl (28.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.31+ ARM64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

pyvoy-0.1.2-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.2-cp310-cp310-manylinux_2_31_aarch64.whl (28.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.31+ ARM64

pyvoy-0.1.2-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.2-cp314-cp314-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.2-cp314-cp314-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 17606c3d7c5b9adffb7b4833772c1656924414685ea26747751c3a666b2ef15f
MD5 1b517170d408c38a44da1207b4a5d882
BLAKE2b-256 2d3a2b8a0300e6bba250f724186f5eacd11e34afe69a358a91333ed4b274b4e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.2-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.2-cp314-cp314-manylinux_2_31_aarch64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.2-cp314-cp314-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 aef91cc81a7a584d937e12b2fa2baae451913a642c44eb8d771008da233b8e40
MD5 d106710dc0e3a4c79bea76c1d441681c
BLAKE2b-256 58671777827471efa575ae9586dc3b7ab4b331a15dbccf3d40f2c05311700574

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.2-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.2-cp314-cp314-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.2-cp314-cp314-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 57bff2093d4d2958c9f2b50f67cc2e6ae9d53adc6de3d0a7a2c9d3d36f6f5b53
MD5 66d1ca2c5ce5353651898b52f39321e5
BLAKE2b-256 7dc0731370402d774b41b786638d15a3378a5c1e2fe482032b7b40df6c90dadf

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.2-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.2-cp313-cp313-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.2-cp313-cp313-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 1caa920cee4b8a79ca3bb4e4788b0cfc7005dab396b2d892819c7e50f918d670
MD5 0020468dda79b47a5e84dc631073e59a
BLAKE2b-256 97e37a24e69471f3a400f39f82e5195af765ef124339b9d7a98620c27658312c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.2-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.2-cp313-cp313-manylinux_2_31_aarch64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.2-cp313-cp313-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 3cf86b31e007e8a2483c92ede7bc9c959600eebbfd1ac1254ddabce119333360
MD5 4d9321c1c9ff351687597dc7f877afdb
BLAKE2b-256 f5d3cc2b423945ccf79ea9a6550aada535d655f32939bcbb69a594ad43e6f791

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.2-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.2-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.2-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 04c2654124c8097dc0a904c8cd1896ef072c23e1e40997501c39a29074b9f16f
MD5 2e86bbcc3fc040c20ec2be4bb01c48a9
BLAKE2b-256 6fd5d16ff5de8f1372f2ba0170ffcace1a79482dcfdfdd64f625d3e959cb3699

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.2-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.2-cp312-cp312-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.2-cp312-cp312-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 3437e4bcbc3f9c230ed974f0506e1d507c61385ba49def114eff52f12ce088d3
MD5 ac0b5d36ecbcb531d45a7a533e81a50b
BLAKE2b-256 a8cff52e33f141da7c026c0dfc922178b0a902f5e5486cffd5da1ba23796feaf

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.2-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.2-cp312-cp312-manylinux_2_31_aarch64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.2-cp312-cp312-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 773c9c13a3b0d13b7bddc3b3f6c93fd5298e792269bec6a21a3801b940c418af
MD5 7d73e8ba76d599b75748220ef8c658b6
BLAKE2b-256 72f9ddb769f361a7644aec083cadc180d6d963fdf3e0838a993c4c5a67573a4e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.2-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.2-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.2-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 82f6db5874a104b4dc058f5998ab4b7b8dd5d2158b3fe1812447141df3bcf0af
MD5 3b1875ba92ba54f237aa8425fd0884a5
BLAKE2b-256 ceb348e54808f68efd4641aad5dec361b2119754f7ad8c95ae18a7f1027c4005

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.2-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.2-cp311-cp311-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.2-cp311-cp311-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 8489b03ae6b0dc833d09997ec960dfff6afbfee891c60a42d21342dbe8016dde
MD5 9d432abf041bc4e24cf3fd60724b76da
BLAKE2b-256 2250b99b6b4e6f5cf6b69449b7f305fcb83dc92da63143bbbff6bcdda81f0633

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.2-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.2-cp311-cp311-manylinux_2_31_aarch64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.2-cp311-cp311-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 d099e4124aa90c1ef4b24c53e8024f948c29d5a99d924740e0181ab14e8022c5
MD5 11deb5fe53bad1bcf660d0447505f25b
BLAKE2b-256 7be4be897bfe763bbff972e77780d1f203edc2c9a3410a38aeb811eb9ba064cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.2-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.2-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.2-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 8b0fef26ca9d380c3ea52c5236df29e8f98600a10fe56ae7c6377b92da68456d
MD5 f6b2b6f2c1227e4afcadba11538fc334
BLAKE2b-256 df8903aa01547af96dd7aa9be359a572b924e1f688c074ef45e553dbc0f2db3d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.2-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.2-cp310-cp310-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.2-cp310-cp310-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 cc7eb5dea99f267bb1796bd63d3439ebcebf9df4acdf133dfaf4b66257907003
MD5 010dd5e2e15b9b3d5028216c01fa2f61
BLAKE2b-256 c8f1d962f4d77ab40e75ad069d8c861f94a32c988732de19db6737e7155d6811

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.2-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.2-cp310-cp310-manylinux_2_31_aarch64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.2-cp310-cp310-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 d12939bdd01f45f64c9757eafcc6dbbffee0b5cd5d69a41982237763ff4c8908
MD5 686f7c440096a158eecb73bef28ac6c9
BLAKE2b-256 19ea060de57934ee2ce0ea23db830cf400c4786056505103def9d9d1255ce59c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.2-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.2-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.2-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 8d449ee02cf1fe1c0f5858ac3c81e39d9ffb5033a03f07ecec4948295f6fae89
MD5 6dc9da1f9220c6e4d42042d9483a6e08
BLAKE2b-256 d3afbfb318526b6d86c1cb1c8437b5ec5d751467397a0c233ec8d03ccaee43a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvoy-0.1.2-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