Hi everyone,
I’m happy to announce the release of Hornbeam 1.0.0, a WSGI/ASGI server that runs Python web applications on the Erlang VM.
Background
Hornbeam was the project that led me to create Erlang_python - embed Python in Erlang/Elixir . I needed a way to run Python web apps with Erlang’s concurrency model. The result is a server that lets you run standard Python frameworks while leveraging the BEAM for scaling, distribution, and fault tolerance.
What is it?
Hornbeam lets you run standard Python web frameworks (Flask, FastAPI, Django, Starlette) while leveraging Erlang’s concurrency,
distribution, and fault tolerance. Python handles the web logic and ML, Erlang handles the scaling.
Built on Cowboy for HTTP and erlang_python for Python integration.
Performance
Benchmarks against Gunicorn (4 workers, gthread):
┌─────────────────────────┬──────────────┬─────────────┬─────────┐
│ Test │ Hornbeam │ Gunicorn │ Speedup │
├─────────────────────────┼──────────────┼─────────────┼─────────┤
│ Simple (100 concurrent) │ 33,643 req/s │ 3,661 req/s │ 9.2x │
├─────────────────────────┼──────────────┼─────────────┼─────────┤
│ High concurrency (500) │ 28,890 req/s │ 3,631 req/s │ 8.0x │
├─────────────────────────┼──────────────┼─────────────┼─────────┤
│ Large response (64KB) │ 29,118 req/s │ 3,599 req/s │ 8.1x │
└─────────────────────────┴──────────────┴─────────────┴─────────┘
Features
- Full WSGI (PEP 3333) and ASGI 3.0 support
- ASGI lifespan protocol for app startup/shutdown
- WebSocket with pg-based pub/sub
- Python access to ETS for shared state
- Distributed RPC to remote nodes via hornbeam_dist
- HTTP/2 via Cowboy
Erlang Integration from Python
from hornbeam import state, rpc_call, broadcast
Shared state via ETS
state.set(“key”, value)
state.incr(“counter”)
RPC to remote nodes
result = rpc_call(‘gpu@ml-server’, ‘model’, ‘predict’, [data])
Pub/sub
broadcast(“topic”, {“event”: “update”})
Quick Start
hornbeam:start("myapp:application", #{
bind => <<"0.0.0.0:8000">>,
worker_class => asgi,
workers => 4
}).
Links
- Hex: hornbeam | Hex
- Docs: https://hornbeam.dev
- erlang_python: GitHub - benoitc/erlang-python: Execute Python from Erlang using dirty NIFs with GIL-aware execution, rate limiting, and free-threading support
- GitHub:
Apache 2.0 licensed. Feedback and contributions welcome.