Hornbeam

Hornbeam

Apache 2.0

WSGI/ASGI HTTP server and application server for Python on Erlang. Your Python code. Erlang's infrastructure.

Protocol Support

Full compliance with Python web standards.

WSGI

PEP 3333

Flask, Django

ASGI

ASGI 3.0

FastAPI, Starlette

WebSocket

RFC 6455

Real-time apps

HTTP/2

Via Cowboy

Multiplexing

Erlang Superpowers

Access Erlang features directly from Python.

ETS Shared State

In-memory key/value storage. Atomic counters. Concurrent-safe.

Distributed RPC

Call functions on remote nodes. Built-in clustering.

Pub/Sub

pg-based messaging. Real-time notifications.

ML Caching

Cache inference results in ETS. Automatic deduplication.

Hot Reload

Update without restart. Zero downtime deployments.

Hooks

Extend behavior with Erlang callbacks.

Quick Start

1. Add to rebar.config
{deps, [
  {hornbeam, {git,
    "https://github.com/benoitc/hornbeam.git",
    {branch, "main"}}}
]}.
2. Run your app
%% WSGI
hornbeam:start("app:application").

%% ASGI (FastAPI, etc.)
hornbeam:start("app:app", #{
  worker_class => asgi
}).

Python API

hornbeam_erlang module
from hornbeam_erlang import (
    state_get, state_set, state_incr,  # ETS shared state
    rpc_call, rpc_cast, nodes,          # Distributed RPC
    publish,                             # Pub/Sub
    call, cast                           # Erlang callbacks
)

# Shared state
state_set('user:123', {'name': 'Alice', 'score': 100})
user = state_get('user:123')
views = state_incr('page:views')

# Distributed RPC
result = rpc_call('gpu@server', 'ml', 'predict', [data])
connected = nodes()

# Pub/Sub
publish('events', {'type': 'login', 'user': 123})

ML Integration

hornbeam_ml module
from hornbeam_ml import cached_inference, cache_stats

# Automatically cached by input hash
embedding = cached_inference(model.encode, text)

# Check cache performance
stats = cache_stats()
# {'hits': 100, 'misses': 10, 'hit_rate': 0.91}

vs. gunicorn

Feature gunicorn Hornbeam
Concurrent connections ~1000s (GIL) Millions (BEAM)
Shared state Redis/Memcached Built-in ETS
Distribution Redis/RabbitMQ Built-in RPC
Hot reload Restart workers Live code swap
Fault tolerance Manual Supervisors