Overview
A PicoMQ deployment has three components. Nodes serve clients and hold only caches. An object store holds the data objects. A SQL database holds the metadata log that coordinates the nodes. The write-ahead log lives in either the object store or the SQL database.
| Component | Holds | Options |
|---|---|---|
| Node | Caches | pico serve process, or a background worker inside Postgres |
| Object store | Data objects, WAL by default | S3 and compatible stores, local filesystem |
| SQL database | Metadata log, optionally the WAL | Postgres, SQLite for a single node |
Anatomy of a node
Each node runs the same stack. An HTTP listener speaks the Pico protocol or Durable Streams, a Kafka listener serves Kafka clients, and an admin listener serves the admin API and the console. Behind them:
- The ownership router decides whether this node serves a partition or redirects, see Ownership and routing.
- The topic layer maps names to topics, partitions, and logs, see Topics and streams, and the group coordinator runs consumer groups.
- The
s3streamengine moves records to and from storage.
The engine is the only writer of record data. It appends to a write-ahead log for durability, batches records into larger data objects in the background, and serves reads from caches when it can.
The metadata log
All cluster state changes are commands, such as registering a node, opening a stream, committing an object, or fencing a dead node. The full list is in Metadata. A node proposes a command to the SQL database, where an ordered log table assigns it a position. Every node tails that table and applies each command to an in-memory state, so all nodes converge on the same view without talking to each other.
The database provides the ordering, which is the property a consensus protocol would otherwise supply. Applying a command is deterministic, so replaying the log always produces the same state. Every 1024 applied commands a node writes a snapshot row and the log below it can be truncated, which keeps replay on startup short. The position of the last applied command is the applied index seen in the admin API.
The applied state answers every routing and placement question: which node owns a stream, which objects exist, which transfers are in flight. Nodes read it from an immutable in-memory view, never from SQL directly, so reads cost nothing and a slow database only delays new commands.
Request routing
Any node accepts any request. A request for a partition owned elsewhere gets a 307 redirect to its owner over HTTP, or NOT_LEADER_OR_FOLLOWER over Kafka. Fencing backs this up, so a stale view can cost a hop but never split a stream. The rules are in Ownership and routing.
Background work
A few loops run outside the request path. Some run on every node, the rest only on the node holding the SQL lease. None of them is a special role: whichever node holds the lease does that work, and losing it moves the work elsewhere.
| Loop | Runs on | Does |
|---|---|---|
| Tailer | Every node | Applies the metadata log and publishes views |
| Heartbeat | Every node | Keeps the node live, and stops it once it is fenced |
| Transfer watcher | Every node | Hands off or takes over streams in a transfer |
| Deleted cleanup | Every node | Destroys owned streams whose topic was deleted |
| Compaction check | Every node | Starts compaction for streams with too many objects |
| Snapshot | Whichever node crosses the interval | Writes the next snapshot |
| Failover | Lease holder | Fences silent nodes and moves their streams, see Failover |
| Object expiry and cleaner | Lease holder | Reclaims abandoned uploads and deletes destroyed objects, see Garbage collection |
| TTL sweep | Lease holder | Deletes topics whose TTL lapsed |
| Token expiry | Lease holder | Removes expired tokens |