NATS
2.x (JetStream)Summary
High-performance cloud-native messaging system supporting at-most-once pub/sub, request-reply, and durable JetStream (at-least-once and exactly-once) streams : designed for low latency and operational simplicity with sub-millisecond delivery at high throughput.
Primary Use Case
Low-latency microservice communication, IoT device telemetry ingestion, event streaming with JetStream, service mesh messaging, and workloads requiring Kafka-like durability with significantly lower operational overhead.
Consistency & Transactions
Scaling
Read scalability
Consumer groups in JetStream allow multiple consumers to share message load. NATS clustering distributes subjects across cluster nodes; clients connect to any cluster member and messages route automatically. Leaf nodes extend the cluster geographically without full mesh connectivity.
Write scalability
JetStream streams receive messages to a persistent log. Multiple producers can publish concurrently. Throughput scales with cluster node count and NVMe I/O. Core NATS (no JetStream) achieves millions of messages/second in memory.
Failure Behavior
Known failure modes
- ·Core NATS is fire-and-forget: if no subscriber is connected, messages are dropped silently
- ·JetStream stream storage exhaustion causes publish failures if limits are not configured
- ·Cluster split-brain during network partition: NATS uses Raft for JetStream leader election
- ·Consumer ack timeout redelivery loops if processing is slower than ack_wait duration
Degradation patterns
- ·Slow consumers in push-mode JetStream cause server-side buffer growth and memory pressure
- ·High replication factor (R3) increases publish latency by requiring quorum acknowledgment
- ·Large message payloads (>64KB) reduce throughput; design for small messages
Recovery considerations
- ·JetStream stream data survives server restart if file_store is configured
- ·Cluster failover: Raft election completes in seconds; brief unavailability during leader re-election
- ·Message replay from JetStream stream provides event sourcing-like recovery for consumers
Architecture Guidance
Common topology roles
Migration notes
- ·NATS JetStream vs Kafka: NATS provides dramatically simpler operations (single binary, no ZooKeeper/KRaft complexity) with a slightly lower throughput ceiling: choose NATS when operational simplicity is the priority
- ·NATS does not support consumer group lag monitoring tooling as mature as Kafka's ecosystem; build custom observability on JetStream consumer pending counts
- ·Migrating from Kafka: NATS subjects map to Kafka topics; JetStream consumers map to Kafka consumer groups; replication factor maps to stream R value
Advisor Guidance
When: scenario needs event streaming with lower operational complexity than Kafka
NATS JetStream provides durable streaming with single-binary deployment; evaluate if Kafka ecosystem tooling (Kafka Connect, KSQL) is required before choosing
When: scenario requires request-reply RPC between microservices
NATS core pub/sub with request/reply semantics provides sub-millisecond service mesh communication without gRPC infrastructure
Comparison Factors
operational complexity
Low: single binary, no external dependencies (no ZooKeeper)
latency
Sub-millisecond: lowest latency among durable message brokers
durability
Strong with JetStream and replication; core NATS is ephemeral
cost
Open source; operational cost lower than Kafka due to simpler infrastructure
Basis
NATS JetStream is a production-grade messaging system with documented benchmarks and case studies; the core NATS server and JetStream implementation are thoroughly documented in official NATS documentation
Related Architecture Knowledge
Outbound: this entity affects
NATS provides durable messaging with JetStream; Redis provides in-memory caching and pub/sub. NATS is used for reliable event delivery; Redis is used for low-latency session state and rate limiting, with both used in the same application stack.
Full relationship →NATS JetStream consumer groups distribute messages across multiple consumer instances, implementing competing consumers with at-least-once delivery.
Full relationship →NATS provides sub-millisecond pub/sub messaging with subject hierarchy and wildcard subscriptions, enabling publish-subscribe communication between services.
Full relationship →