Services

Resources

Company

NATS JetStream

NATS JetStream is the persistence engine built into the NATS server. Core NATS delivers messages only to subscribers that are connected at that moment. JetStream stores messages in streams, so consumers can read them later, replay them and acknowledge them. This gives at-least-once delivery and durable subscriptions without running a separate broker.

How it works

A stream captures messages published on one or more subjects and stores them on disk or in memory, with limits on age, size or message count. A consumer is a named view over a stream that tracks which messages it has delivered and which were acknowledged. In a cluster, each stream has a replication factor, and JetStream uses the Raft consensus algorithm to keep replicas consistent. A stream with 3 replicas needs a quorum of 2, so it keeps working if 1 server fails.

Why it matters in production

JetStream changes NATS from a fire-and-forget bus into a stateful system. You now plan persistent volumes, an odd number of servers for quorum, and stream limits so disks do not fill. Unacknowledged messages and consumer backlog become the numbers to watch.

See also

On the One2N blog

References

  1. Origin of the term

  2. NATS documentation: JetStream

Four-panel comic explaining NATS JetStream. NATS JetStream is the persistence layer built into the NATS server, adding stored streams, replay and at-least-once delivery to NATS messaging.