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

Uploaded CPython 3.14manylinux: glibc 2.31+ ARM64

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

Uploaded CPython 3.14macOS 15.0+ ARM64

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

Uploaded CPython 3.13manylinux: glibc 2.31+ ARM64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

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

Uploaded CPython 3.12manylinux: glibc 2.31+ ARM64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

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

Uploaded CPython 3.11manylinux: glibc 2.31+ ARM64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

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

Uploaded CPython 3.10manylinux: glibc 2.31+ ARM64

pyvoy-0.1.3-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.3-cp314-cp314-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for pyvoy-0.1.3-cp314-cp314-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 deea0f750b7d3bae1a105957ee93d3db6977edc08e7120cd950ca770b8ccfd8c
MD5 6b25de64e329f9a41fabc5c1b9fa6d46
BLAKE2b-256 4964d7b05b3f411c1918d475e15691e165e28c20262b7820a2ef32ff7d3918be

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvoy-0.1.3-cp314-cp314-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 15681a2711b9ae434fa0a749d654be2e126a1939fd3f7f2cc118ece4489e0d55
MD5 3d20f292bf6981a837d79ec3678a625f
BLAKE2b-256 51cc684ec1c3dd83173c5f41eeabe1102436229d1353c467d6d425e350567d86

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvoy-0.1.3-cp314-cp314-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 ce31c607d3cfc90047e5be1a54c58d804750ab42c9f4106930bc4ba3f58745a5
MD5 9dfc253c6a6ad17058f60c594efde8fd
BLAKE2b-256 98eb5e81b1c9a01f4f858c3bbf39b90f384434e0eb648bb280b3f319f561a6fb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvoy-0.1.3-cp313-cp313-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 9a1eb418bd8d2299a3ebc738601d5e07427f3f393c9bd0f1c94083bd42625b5b
MD5 4b77d6513f9af9c18ac567c7df36ff9d
BLAKE2b-256 63dcc86070e340f53af29f2e4a450b8b972ae0a8a6a33faaddbaaa96b9e40376

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvoy-0.1.3-cp313-cp313-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 b2ea04fe830074afb22b52b9588e9d19072c453ef2b38b7ca997bc77e6d8cd47
MD5 ba1d908a742475cbbc5fd60390dd7de8
BLAKE2b-256 6c4157b91da8c05167ff1eff13a9fdb11eaf94f6adbec5f5f6dfb144c54e8037

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvoy-0.1.3-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 1a0503b90d0128f54bbf73aa4b5fd1e0fb59f278870bb793558613ce30bb30c0
MD5 bbdc12e253733fb7a673f180b88c7858
BLAKE2b-256 d223fad80674fd9e6ea60d4355ae61bbade51916c9f1d5a9de7f4f3220ea8a2a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvoy-0.1.3-cp312-cp312-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 17865a70d3643d9308313146b55c8f1d91b32faa2dddfd09be7bc89127c82b90
MD5 b6af9a785b989530e290e9511e6bd0ea
BLAKE2b-256 92806678d754fed5d4427e43df7947c914d3559e34b161873f5ae19b45653495

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvoy-0.1.3-cp312-cp312-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 a2d784175dd90462343c81f033fcadac42bd4e37c7772fea4f1f839f68391786
MD5 e60b0664b3d4131307a5b0d34b100788
BLAKE2b-256 0f1acffc8940a13a77bef328b1d718ce9c09bc7d24a0c9e562906763aa216dd8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvoy-0.1.3-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 ccf448a8fb65bf6d95beb8864f9af30b9491c128e02df2494cf0bf315d2a7793
MD5 9c23ca5faa4739c8bbe35f6cb6cd0575
BLAKE2b-256 46b0e9f8726a1631d6545e6f2c009ebf19e380c92208ba69920ec75da991675c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvoy-0.1.3-cp311-cp311-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 33f9d1b1842ae9b2fa681729dfa94f4fcf438583ce761c3eb875c230735ab181
MD5 1410b0d223c43e0299d291220dd4ff88
BLAKE2b-256 629254aaf8d47747b800b7252511eacce2ab2efdc4ea19573546f10db99b08ff

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvoy-0.1.3-cp311-cp311-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 701468902bf6f2dc6152d45188cfce689f6d00135da88e8e2ca47de78802c153
MD5 14ce41e3f7accdfebbcb28b17d931584
BLAKE2b-256 e5f836670c743f89cd58e40bd3eb23a5cbe828fad48413991f6185cad11a2ba6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvoy-0.1.3-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 1c93eaea7748ff1b4918f81b1c86aa5fcbf95cf9b795bc09af8c34988fc62fac
MD5 28c39ef719cdc245347d49aeb4e45fb0
BLAKE2b-256 d540fba466e9a47d3e4b366a01cf1bc8d0f691675e236c50d923625f3e3456b2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvoy-0.1.3-cp310-cp310-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 e6d69ee3105d83b39a732fb12e223e47f5b369459912983722b178d2e4e1fe42
MD5 c76d867fdb04d90971070d3f8c4c9316
BLAKE2b-256 5377094b5542875fdfaccb70f70616f9c2edc5bdda1f8debc4113168f4b02f93

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvoy-0.1.3-cp310-cp310-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 6f62c8e4361bb62d2b0eccc13e6609c172b442530b6a508e9c894742fc4cacd5
MD5 c9a59e98fb16eb780015b2973f4380b1
BLAKE2b-256 f15f730df4ad7d49769a490ac8a24c262632fa057f48851425f2a9d10759b046

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvoy-0.1.3-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 b5cdbf5c2669e8a88e5d557f5737a483a4ad248be98dadc4d27750cc37b33154
MD5 a5273983196807120308818568f64c5f
BLAKE2b-256 9bc463239f5520df55a36f54f67063b5d8aa3504dcc1d20ab30428cdebe22eb2

See more details on using hashes here.

Provenance

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