Redis and Valkey streams for Python
RillKit consumes Redis and Valkey streams for you: consumer groups, retries with backoff, a dead-letter queue and a clean shutdown, around a function you write. Turn on the optional control plane and you can watch, pause, scale and replay every worker from one dashboard, and see where a message spent its time at every step it crossed.
pip install rillkitSimple by default
The publisher and the worker agree on "orders" and nothing else. No schema to register, no polling loop, no ack bookkeeping.
pip install rillkitPoint RILLKIT_URL at Redis or Valkey: one server or a cluster.@broker.subscribe(Stream(...))Name a stream and a group. Your function gets each message as a dict or a Pydantic model.broker.run()Groups, retries, the DLQ, heartbeats and a clean shutdown on Ctrl-C come with it.from rillkit import Broker
broker = Broker.from_env() # reads RILLKIT_URL
broker.publish("orders", {"id": 1, "total": 42.5})from rillkit import AckPolicy, Broker, Message, Stream
broker = Broker.from_env() # reads RILLKIT_URL
@broker.subscribe(
Stream("orders", group="workers"),
ack_policy=AckPolicy.NACK_ON_ERROR,
max_retries=3,
)
def handle(order: dict, msg: Message):
if order["total"] <= 0:
msg.reject("bad total") # straight to the DLQ
return
if not charge(order):
msg.nack() # try again after a backoff
broker.run()The control plane · optional
Set RILLKIT_CONTROL=relay and each worker reports to rillkit-server. Its dashboard shows every stream, worker and message, traces each message across streams, and lets you pause, scale and replay them. No code changes, and the library works the same without it.

Workers dial out
Each worker opens one outbound WebSocket to the server. Telemetry goes up every few seconds; directives come back down. The server does not touch your Redis or Valkey.
RILLKIT_CONTROL=relay, a URL and an API key.Autoscale on load
Give a stream a minimum, a maximum and a target lag per worker. The autoscaler follows the arrival rate and the backlog, adds lanes when work builds and removes them when the rate falls — not just when lag hits zero.
Messages, as they arrive
Newest first, as of a moment you choose or live as messages land, each with its status: waiting, pending with its try number, or acked. Open one in place for its payload, its trace id, its logs, and View trace: every stream the trace crossed, with queue wait against handler time.

Find the bottleneck
Queue wait against handler time for every stream, and one trace across every stream a message crossed — including retries — on one time ruler. The slow step is obvious without opening a tracing stack.

Fix and replay the DLQ
Page through dead letters with the reason each one failed and the logs of every attempt. Replay one, a selection or all of them, delete them, or correct a payload that could never succeed and replay just that message.

One stream, one node or the whole fleet. Paused workers finish the message in hand; drained ones also let go of their consumers.
Every change is a directive with an id. Any worker applies it once, answers, and it is listed in Activity with who sent it.
Messages handled, success rate, data rate and DLQ size, with the change against the previous window: green when better, red when worse.
Queue wait against handler time per stream, and one trace across every stream a message crossed, so the slow step is obvious. Traces are opt-in metadata, kept for an hour.
What a handler logged for one message, attempt by attempt, with its exception and W3C trace id. Opt in with RILLKIT_CAPTURE_LOGS.
The server stores neither payloads, logs nor trace records. It asks a worker when you open a message or a trace, and only if that worker allows it.
Raise or lower a stream’s worker lanes per node from the dashboard; workers apply it without a restart, and the autoscaler can do it for you.
Run as many servers as you like on one Postgres. Directives reach a worker through whichever replica holds its connection.
GET /api/metrics exports replica, tenant, node, lane, in-flight, lag, pending and ack-rate gauges for your existing scrape.
One download starts Postgres, Valkey, rillkit-server with its dashboard, two demo workers and a producer whose load rises and falls, so lag builds, the autoscaler reacts and failures land in the DLQ. A flow service sends one traced order through two streams every two minutes. The images are published: no clone, no build.
Run the serverTour the dashboardConnect workers
The SDKs are Apache 2.0. rillkit-server and the dashboard are FSL-1.1-ALv2: free to self-host for your own organization, and Apache 2.0 two years after each release.
$ curl -fsSLO https://raw.githubusercontent.com/\
NimzyMaina/RillKit/main/deploy/demo.yaml
$ docker compose -f demo.yaml up -d
# open http://localhost:8080
# admin token: rillkit-local-admin-tokenIt goes from publish to the handler, then takes one of three exits. There is no fourth one where it quietly disappears.
Most teams start with xreadgroup in a while True. It works until the first exception. The migration example runs both versions side by side.
import json
import redis
r = redis.Redis.from_url("redis://localhost:6379/0", decode_responses=True)
try:
r.xgroup_create("orders", "workers", id="0", mkstream=True)
except redis.ResponseError as e:
if "BUSYGROUP" not in str(e):
raise
while True:
for _, entries in r.xreadgroup("workers", "web1", {"orders": ">"}, count=10, block=5000) or []:
for entry_id, fields in entries:
try:
charge(json.loads(fields["data"]))
r.xack("orders", "workers", entry_id)
except Exception as e:
print("failed:", e) # and then?from rillkit import Broker, Stream
broker = Broker.from_env()
@broker.subscribe(Stream("orders", group="workers"))
def handle(order: dict):
charge(order)
broker.run()The group is created for you and every worker gets its own consumer name. Entries left with a crashed worker are claimed back once they have sat idle long enough.
A failing message comes back after an exponential backoff, up to max_retries. The default is 3, so a handler runs at most four times for one message.
msg.nack() asks for another attempt. msg.reject("reason") says this one can never work and skips the remaining retries.
Entries that run out of retries, or are rejected, move to <stream>-dlq with the error, original id, group and delivery count. broker.replay_dlq() puts them back.
Choose when a message counts as done. Set it per handler with ack_policy=. Details
| Policy | Handler returns | Handler raises | |
|---|---|---|---|
NACK_ON_ERRORdefault | ack | retry | At-least-once. Failures are retried, then dead-lettered. |
ACK_ALWAYS | ack | ack | Failures are logged and dropped, never retried. |
ACK_FIRST | acked before | acked before | At-most-once. A crash mid-handler loses the message. |
MANUAL | you call msg.ack() | retry | RillKit never acks. Return without acking and it is retried. |
Groups, pending entries and the dead-letter stream are ordinary stream structures. When something looks off at 2am, redis-cli or valkey-cli shows you what RillKit sees.
XACK and leaves the pending list. lag: 0 means the group has read everything.claim_idle_ms times the backoff.orders-dlq with the original body plus five x- fields saying where it came from and why it stopped.127.0.0.1:6379> XINFO GROUPS orders
1) 1) "name"
2) "workers"
3) "consumers"
4) (integer) 2
5) "pending"
6) (integer) 1
7) "last-delivered-id"
8) "1730032645250-0"
9) "entries-read"
10) (integer) 7
11) "lag"
12) (integer) 0
127.0.0.1:6379> XPENDING orders workers - + 10
1) 1) "1730032643012-0"
2) "workers-web1-4242"
3) (integer) 6210
4) (integer) 2
127.0.0.1:6379> XRANGE orders-dlq - + COUNT 1
1) 1) "1730032645261-0"
2) 1) "data"
2) "{\"id\": 7, \"total\": -5}"
3) "x-original-id"
4) "1730032645250-0"
5) "x-stream"
6) "orders"
7) "x-group"
8) "workers"
9) "x-error"
10) "bad total"
11) "x-deliveries"
12) "1"You need Python 3.9 or newer and a Redis or Valkey server you can reach. Local Docker is fine. The guide walks through the same steps with more explanation, then covers retries, the DLQ and running several workers.
Read the getting-started guideExamplesThe control planeAPI reference
# a server, if you do not have one (or redis:7)
$ docker run -d -p 6379:6379 valkey/valkey:8
$ pip install rillkit
$ export RILLKIT_URL=redis://localhost:6379/0
$ python worker.py # terminal 1
$ python publish.py # terminal 2