Quickstart
The shortest path to a running Felix cluster with something happening on it.
This page targets main (the 0.7 line), so the compose file and the Rust
example below match the code you build from a clone. For 0.6.2 or earlier, use
the stable docs at https://docs.getfelix.dev/.
A broker on its own is not a working system: it authenticates every connection against a control plane, so it needs one to talk to and a credential to present. Both ways of starting Felix below set all of that up for you, which is why they come first here rather than last.
Try it in one command
Section titled “Try it in one command”With Docker or Podman and nothing else, this runs a control plane, a broker and development credentials from the 0.7 images:
curl -fsSLO https://raw.githubusercontent.com/GetFelix/felix/main/compose.yamldocker compose up -ddocker compose logs felix-dev-readyWith Podman, use PODMAN_COMPOSE_PROVIDER=docker-compose podman compose up -d;
podman-compose does not run this file correctly.
The last command prints the connection settings once the broker is ready. Then publish three records and read them back from the start of the stream:
docker compose run --rm felixctl pub orders 'hello' --count 3docker compose run --rm felixctl sub orders --from earliest --count 3sub prints hello three times and exits. Without --count it keeps
waiting, so you can run sub orders in one terminal and publish from another
to watch records arrive live. Tear the stack down with docker compose down -v.
The broker keeps its data on disk in the stack’s volume, so orders is a
durable stream and the config and stats caches can be watched, counted in
and read back. The use cases each end with a short “Try
it” that runs against this stack.
This stack’s broker has no node id, so it runs standalone, on the older hybrid
shard engine, and logs a warning saying so. A clustered broker runs Raft.
felix-cluster up below also runs the hybrid engine unless you set
FELIX_SHARD_ENGINE=raft. Both move to Raft in
#2985.
The credentials are for your machine only, and the printed settings show how
to use an installed felixctl instead. See
Docker Compose for what
the stack runs and why its credentials are safe locally. The rest of this page
builds Felix from source.
Stop here if you only want to try Felix. The tutorials build on this stack and take you from a first stream to a small app.
Prerequisites
Section titled “Prerequisites”- Rust 1.97 or later; the repo pins 1.99.1 and rustup fetches it (rustup)
- Git
- Optional: Task, for the shortcuts CI uses
git clone https://github.com/GetFelix/felix.gitcd felixcargo build --releaseUse the release profile for anything you intend to measure. A debug build is several times slower and will mislead you.
A cluster, in one command
Section titled “A cluster, in one command”felix-cluster starts a control plane, mints the credentials, and brings up as
many brokers as you ask for:
cargo run --release -p felix-cluster -- up --nodes 3starting a 3-node cluster...
cluster up.
control plane http://127.0.0.1:52704
node client metricsbroker-0 127.0.0.1:53348 127.0.0.1:52706broker-1 127.0.0.1:65027 127.0.0.1:52707broker-2 127.0.0.1:50410 127.0.0.1:52708
placeable: broker-0, broker-1, broker-2shard ownership: stream/t1/ns/orders/0 -> broker-2
session ${TMPDIR:-/tmp}/felix-cluster.json
holding the cluster. press Ctrl-C to tear it down.The session file sits in your system temp directory ($TMPDIR, or /tmp). It records the tenant
(t1), namespace (ns), a client token and every broker’s address, and it is
how the other commands find the cluster.
It holds until you interrupt it. In a second window, subscribe:
cargo run --release -p felix-cluster -- subscribe orderssubscribing to orders on broker-2 (owner)waiting for events. Ctrl-C to stop.And in a third, publish:
cargo run --release -p felix-cluster -- publish orders "hello"published "hello" to orders via broker-0 → forwarded to broker-2 → acknowledgedThe subscriber prints it with its log offset:
[broker-2] offset 1 helloThat line is the whole model in miniature. The stream’s shard is owned by
broker-2, you published through broker-0, and broker-0 forwarded the
record to the owner and waited for it to be written before acknowledging. Which
broker you connect to is a routing detail, not a correctness one. The
acknowledgement says when forwarding happened, so a client can see that it is
paying for a relay on every record.
The rest of the cluster commands
Section titled “The rest of the cluster commands”cargo run --release -p felix-cluster -- smoke # publish through a non-owner, receive from the ownercargo run --release -p felix-cluster -- demo # the cross-broker story, paced for readingcargo run --release -p felix-cluster -- failover # kill the leader, keep publishingcargo run --release -p felix-cluster -- consistency # what Quorum buys and Leader costs, under a faultcargo run --release -p felix-cluster -- status # membership and shard ownership, then exitup first for subscribe and publish; the others start their own cluster.
With felixctl
Section titled “With felixctl”felixctl works against the same cluster
and covers more: keyed and idempotent publishes, subscribing from an offset,
cache reads and watches, shard owners, creating streams and caches, moving
shards, draining brokers and benchmarks.
That page shows how to turn the session file into a felixctl context.
One process, no cluster
Section titled “One process, no cluster”If you would rather see the data path than the cluster, the demos embed a broker in-process and need nothing running:
cargo run --release -p felix-broker-service --features demo --bin pubsub-demo-simple== Felix QUIC Pub/Sub Demo ==Goal: demonstrate publish/subscribe over QUIC (not cache).This demo spins up an in-process broker + QUIC server, then runs a client.Step 1/6: booting in-process broker + QUIC server.Step 2/6: connecting QUIC client.Step 3/6: opening a subscription stream.Subscribe response: SubscribedStep 4/6: publishing two messages on the same stream.Step 5/6: receiving events.Event on demo-topic: helloEvent on demo-topic: worldShutting down demo.Demo complete.Others worth running: cache-demo, queue-semantics-demo,
durable-restart-demo, pubsub-demo-orders, latency-demo. Each is
self-contained and prints what it is proving as it goes.
Running a broker yourself
Section titled “Running a broker yourself”cargo run --release -p felix-broker-serviceOn its own this starts and then stops:
INFO felix_broker_service::node: broker startedError: FELIX_CONTROLPLANE_URL must be set for authThat is deliberate. A broker validates every client token against its tenant’s signing keys, which it fetches from the control plane, and a clustered broker registers itself there so shards can be placed on it. There is no unauthenticated mode to fall back to.
So running brokers yourself means running a control plane, pointing each broker at it, and giving each one a node credential:
- Locally,
felix-cluster updoes all three, and the session file it writes names every address it chose. - On Kubernetes, the Helm chart at
deploy/helm/felixwires them together. See Kubernetes. - With containers, the images are published on every release and pull without credentials. See Installation and Docker Compose. The broker image needs the same control-plane URL and credential as any other broker.
Using the Rust client
Section titled “Using the Rust client”A client connects with a tenant and a Felix token, and it verifies the broker’s certificate. Where each comes from:
- The tenant and token. A client token is a Felix token issued by the
control plane’s token exchange (
POST /v1/tenants/{tenant}/token/exchange) for an identity-provider token; see Security. For afelix-cluster upcluster, the session file holds a ready-made one (tenant_id,namespace,client_token) along with each broker’s client address. - The certificate. A broker without
FELIX_TLS_CERTgenerates a self-signedlocalhostcertificate at every start.FELIX_TLS_CERT_EXPORTwrites it to a file the client can trust. A broker with a certificate from a public CA needs no roots at all: passNoneto use the platform trust store.
Publish and subscribe
Section titled “Publish and subscribe”Make a crate for the example. The client API below is the 0.7 one, so depend on
felix-client from your clone of the repository. Run this from the directory
that contains your felix clone, not from inside it, so the new crate sits
next to the clone:
cd ..cargo new orders-demo && cd orders-democargo add felix-client --path ../felix/crates/sdk/felix-clientcargo add tokio --features macros,rt-multi-threadcargo add anyhow bytes rustls@0.23use std::net::SocketAddr;use std::sync::Arc;
use felix_client::{AckMode, ClientConfig, Client, quic_client_config};use rustls::pki_types::CertificateDer;use rustls::pki_types::pem::PemObject;
#[tokio::main]async fn main() -> anyhow::Result<()> { // Trust the broker's certificate. let mut roots = rustls::RootCertStore::empty(); for cert in CertificateDer::pem_file_iter("broker-cert.pem")? { roots.add(cert?)?; } let quinn = quic_client_config(Some(Arc::new(roots)), true)?;
let mut config = ClientConfig::optimized_defaults(quinn); config.auth_tenant_id = Some("t1".to_string()); config.auth_token = Some("<felix token>".to_string());
// One broker is enough; the client discovers the rest of a cluster. let seeds: Vec<SocketAddr> = vec!["127.0.0.1:5000".parse()?]; let client = Arc::new(Client::connect(&seeds, "localhost", config).await?);
let mut subscription = client.subscribe("t1", "ns", "orders").await?; tokio::spawn(async move { while let Ok(Some(event)) = subscription.next_event().await { println!("offset {:?}: {:?}", event.offset, event.payload); } });
for i in 0..10 { client .publish("t1", "ns", "orders", format!("order {i}").into_bytes(), AckMode::PerMessage) .await?; } Ok(())}Replace 127.0.0.1:5000 with a client address from the session file
(${TMPDIR:-/tmp}/felix-cluster.json, written by felix-cluster up): each
entry of nodes has a client_addr. Replace <felix token> with its top-level
client_token. A felix-cluster broker writes its certificate to broker-cert.pem in its
data directory, and the cert_file of each entry names it. Copy one to
broker-cert.pem in the crate, or change the path in the code.
The stream must already exist in the control plane. felix-cluster up
creates orders in tenant t1, namespace ns. A subscription is served only
by the broker that owns the stream’s shard, and a publish is cheapest sent
straight to it. Client finds that broker and follows it when it
changes, so any broker up prints works as the seed. Use Client for
a single broker too; the plain Connection is a single-connection building block
for tools (see Which client to use).
use bytes::Bytes;
// `client` built as above; the token needs cache.read and cache.write.client .cache_put("t1", "ns", "users", "user:123", Bytes::from_static(b"alice"), Some(60_000)) .await?;
if let Some(value) = client.cache_get("t1", "ns", "users", "user:123").await? { println!("cached: {value:?}");}The cache must exist in the control plane too. felix-cluster up creates one
named users. Rust client covers the rest of the API.
Benchmarks, configuration and troubleshooting
Section titled “Benchmarks, configuration and troubleshooting”- Benchmarks.
latency-demoand current numbers are on Benchmarks;cache-demois covered in the Performance Guide. - Configuration. The broker and the Rust client read
FELIX_*environment variables, and the broker also reads a YAML file. Every option is in the Configuration Reference. - Task shortcuts.
task --listshows the build, test, lint and demo shortcuts. - Troubleshooting. Port clashes and a refused connection are in Troubleshooting.
Where next
Section titled “Where next”- Tutorials: from a first stream to a small app
- felixctl: create streams and publish from the terminal
- Demos: runnable examples of isolation, queues and failover
- Pub/Sub Streaming, Queues and Consumer Groups and Distributed Cache: the three ways to use the log
- Broker API: the wire-level API
- Performance Guide: tuning
- System Design: the architecture
- Deployment: run it properly
- Contributing: the development guide
