Become a sponsor to Ciro Spaciari
This year i started a journey to bring a really fast framework for Http, Http2, Http3 and WebSockets to Python and PyPy.
💡 Features
- WebSocket with pub/sub support
- Fast and realiable Http/Https
- Support for Windows, Linux and macOS Silicon & x64
- Support for
PyPy3
andCPython
- Dynamic URL Routing with Wildcard & Parameter support
- Sync and Async Function Support
- Really Simple API
- Fast and Encrypted TLS 1.3 quicker than most alternative servers can do even unencrypted, cleartext messaging
- Per-SNI HttpRouter Support
- Proxy Protocol v2
- Shared or Dedicated Compression Support
- Max Backpressure, Max Timeout, Max Payload and Idle Timeout Support
- Automatic Ping / Pong Support
- Per Socket Data
- Middlewares
- Templates Support (examples with Mako and Jinja2)
🔎 Upcoming Features
- Fetch like API powered by libuv
- Async file IO powered by libuv
- Full asyncio integration with libuv
- Full Http3 support
HPy
integration to better supportCPython
,PyPy
andGraalPython
- Hot Reloading
We created and adapted the full C API from uNetworking/uWebSockets and will integrate libuv powered fetch and file IO, this same C API is used by Bun
Join Github Discussions
or Discord
for help and have a look at the development progress.
I will use the funds of this sponsorship to get more developers and features in the project, and work full time on bringing socketify to Python, Ruby and more languages.
The problems with japronto and uvloop
Japronto don't get any github updates since 2020 and don't get any src update since 2018, japronto don't support SSL, WebSockets, PyPy3
, Windows or macOS Silicon.
I really needed good support + performance, not only performance.
Almost any solution out there have a really big performance hit when using PyPy3 or are not really fast enougth
The Solution
I discover a really fast, small, and well maintained C++ Library called uNetworking/uWebSockets, but no C API available, so we create and adapt the full C API from uNetworking/uWebSockets and will integrate libuv powered fetch and file IO, this same C API is used by Bun
⚡ Benchmarks
HTTP requests per second (Linux x64)
WebSocket messages per second (Linux x64)
Socketify got almost 900k messages/s with PyPy3 and 860k with Python3 the same performance as Bun that also uses uWebSockets, Falcon at 35k messages/s and Falcon with PyPy3 improves into 56k messages/s, node.js manages 192k.
Runtime versions: PyPy3 7.3.9, Python 3.10.7, node v16.17.0, bun v0.2.2
Framework versions: gunicorn 20.1.0 + uvicorn 0.19.0, socketify alpha, gunicorn 20.1.0 + falcon 3.1.0, robyn 0.18.3
Http tested with oha -c 40 -z 5s http://localhost:8000/ (1 run for warmup and 3 runs average for testing)
WebSocket tested with Bun.sh bench chat-client
Source code in bench
Machine OS: Debian GNU/Linux bookworm/sid x86_64 Kernel: 6.0.0-2-amd64 CPU: Intel i7-7700HQ (8) @ 3.800GHz Memory: 32066MiB
Today socketify has get 30% performance hit due to workarounds between asyncio + libuv, so we will got even faster! See more info in this issue, Python3 and PyPy3 performance will improve when we migrate to HPy. In TechEmPower paintext benchmarks we are the fastest in active web framework for Python/PyPy with more than 2 millions of req/s, followed by Robyn with almost 1.2 million req/s and Falcon using meinheld with about 560k req/s.
Featured work
-
cirospaciari/socketify.py
Bringing Http/Https and WebSockets High Performance servers for PyPy3 and Python3
Python 1,447 -
cirospaciari/socketify.rb
Bringing WebSockets, Http/Https High Peformance servers for Ruby
C 7