[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"stack-nats-en":3},{"data":4,"meta":375},[5],{"id":6,"documentId":7,"title":8,"slug":9,"excerpt":10,"difficulty":11,"estimatedCost":12,"maturity":13,"seoTitle":14,"seoDescription":15,"createdAt":16,"updatedAt":16,"publishedAt":17,"coverImage":18,"category":68,"tags":77,"author":109,"sections":117,"officialLinks":345,"relatedStacks":361,"faq":362},48,"ce8m4d7ioqilmp1v62jl9and","NATS","nats","A high-performance, cloud-native messaging system that simplifies the development of modern distributed systems through publish-subscribe, request-reply, and persistent streaming patterns.","intermediate","Free (Open Source)","stable","NATS: High-Performance Distributed Messaging System","Explore NATS, the lightweight, high-performance messaging system. Learn its architecture, JetStream persistence, strengths, and distributed system use cases.","2026-08-06T10:17:18.257Z","2026-08-06T10:17:18.277Z",{"id":19,"documentId":20,"name":21,"alternativeText":22,"caption":23,"focalPoint":24,"width":25,"height":26,"formats":27,"hash":62,"ext":31,"mime":32,"size":63,"url":64,"previewUrl":24,"provider":65,"provider_metadata":24,"createdAt":66,"updatedAt":66,"publishedAt":67},38,"ot42annjze3ni4yf98u4qjhq","nats-cover","An abstract technical illustration of a high-performance distributed messaging network with interconnected nodes and glowing data streams.","StackAtlas editorial cover",null,1200,630,{"thumbnail":28,"small":38,"medium":46,"large":54},{"name":29,"hash":30,"ext":31,"mime":32,"path":24,"width":33,"height":34,"size":35,"sizeInBytes":36,"url":37},"thumbnail_nats-cover","thumbnail_nats_cover_17ccb8d9a4",".png","image/png",245,129,29.21,29205,"/uploads/thumbnail_nats_cover_17ccb8d9a4.png",{"name":39,"hash":40,"ext":31,"mime":32,"path":24,"width":41,"height":42,"size":43,"sizeInBytes":44,"url":45},"small_nats-cover","small_nats_cover_17ccb8d9a4",500,263,103.33,103332,"/uploads/small_nats_cover_17ccb8d9a4.png",{"name":47,"hash":48,"ext":31,"mime":32,"path":24,"width":49,"height":50,"size":51,"sizeInBytes":52,"url":53},"medium_nats-cover","medium_nats_cover_17ccb8d9a4",750,394,215.56,215559,"/uploads/medium_nats_cover_17ccb8d9a4.png",{"name":55,"hash":56,"ext":31,"mime":32,"path":24,"width":57,"height":58,"size":59,"sizeInBytes":60,"url":61},"large_nats-cover","large_nats_cover_17ccb8d9a4",1000,525,334.96,334962,"/uploads/large_nats_cover_17ccb8d9a4.png","nats_cover_17ccb8d9a4",99.77,"/uploads/nats_cover_17ccb8d9a4.png","local","2026-08-06T10:17:18.015Z","2026-08-06T10:17:18.016Z",{"id":69,"documentId":70,"name":71,"slug":72,"description":73,"createdAt":74,"updatedAt":75,"publishedAt":76},6,"zkbu02m8didnyuum344ap9cg","Distributed Systems","distributed-systems","Consensus, coordination, messaging, caching, distributed storage, and resilient multi-node architectures.","2026-07-15T15:43:57.206Z","2026-08-18T10:16:43.824Z","2026-08-18T10:16:43.811Z",[78,86,94,102],{"id":79,"documentId":80,"name":81,"slug":82,"createdAt":83,"updatedAt":84,"publishedAt":85},8,"kulfumikh6rmscrvyux4vife","Distributed Computing","distributed-computing","2026-07-12T10:16:06.012Z","2026-08-18T10:16:43.961Z","2026-08-18T10:16:43.949Z",{"id":87,"documentId":88,"name":89,"slug":90,"createdAt":91,"updatedAt":92,"publishedAt":93},24,"laqsubu70srpo7gz6p7n3m0e","Key-Value Store","key-value-store","2026-07-21T10:16:16.651Z","2026-08-06T10:17:13.671Z","2026-08-06T10:17:13.664Z",{"id":95,"documentId":96,"name":97,"slug":98,"createdAt":99,"updatedAt":100,"publishedAt":101},50,"es55s72ffz33z2b0z2ie4f51","Pub-Sub","pub-sub","2026-08-06T10:17:13.744Z","2026-08-18T10:16:44.037Z","2026-08-18T10:16:44.031Z",{"id":103,"documentId":104,"name":105,"slug":106,"createdAt":107,"updatedAt":107,"publishedAt":108},49,"xn5xzr6qc7248oan4w9bh27n","Message Broker","message-broker","2026-08-06T10:17:13.709Z","2026-08-06T10:17:13.705Z",{"id":110,"documentId":111,"name":112,"slug":113,"bio":24,"createdAt":114,"updatedAt":115,"publishedAt":116},1,"lv2wpsnmnajx4jmhrvo1zne6","Jose Henriquez","jose-henriquez","2026-07-04T16:49:01.335Z","2026-07-04T16:49:39.022Z","2026-07-04T16:49:39.004Z",[118,154,221,256,287,318],{"id":119,"type":120,"title":121,"content":122},283,"overview","Overview",[123,129,133,137,150],{"type":124,"children":125},"paragraph",[126],{"type":127,"text":128},"text","NATS is a high-performance, open-source messaging system designed specifically for modern, cloud-native distributed systems. Originally developed to serve as the control plane for Cloud Foundry, NATS was later rewritten in Go and is now a graduated project under the Cloud Native Computing Foundation (CNCF). Unlike traditional message brokers that introduce heavy administrative overhead, complex configuration, and significant resource footprints, NATS prioritizes simplicity, speed, and a minimal operational footprint.",{"type":124,"children":130},[131],{"type":127,"text":132},"At its core, NATS operates on a publish-subscribe model, facilitating real-time communication across services, devices, and cloud providers. It is packaged as a single, lightweight binary that can run anywhere—from resource-constrained edge devices to massive Kubernetes clusters. This makes it highly versatile for developers looking to build resilient, distributed architectures without the complexity of managing heavy infrastructure.",{"type":124,"children":134},[135],{"type":127,"text":136},"The NATS ecosystem is divided into two primary operational modes:",{"type":138,"format":139,"children":140},"list","unordered",[141,146],{"type":142,"children":143},"list-item",[144],{"type":127,"text":145},"Core NATS: A high-performance, \"at-most-once\" delivery engine. It acts as a fire-and-forget messaging system, routing millions of messages per second with sub-millisecond latency. If no subscribers are active on a subject, the message is discarded, making it ideal for real-time telemetry, live updates, and high-frequency signaling.",{"type":142,"children":147},[148],{"type":127,"text":149},"NATS JetStream: A built-in persistence engine that adds \"at-least-once\" and \"exactly-once\" delivery guarantees. JetStream enables message streaming, deduplication, consumer tracking, and historical replay. It also provides higher-level abstractions, including a distributed Key-Value Store and an Object Store, all managed within the same server binary without requiring external databases or storage engines.",{"type":124,"children":151},[152],{"type":127,"text":153},"By combining lightweight pub-sub, request-reply patterns, and persistent streaming into a single, unified protocol, NATS simplifies distributed architectures, eliminating the need to deploy separate systems for messaging, caching, and storage.",{"id":155,"type":156,"title":157,"content":158},284,"architecture","Architecture",[159,163,169,173,183,187,191,195,205,209,213,217],{"type":124,"children":160},[161],{"type":127,"text":162},"The architecture of NATS is built around a client-server model where clients connect to a NATS service node (nats-server) over a simple, text-based TCP protocol. The server is designed to be highly resilient, self-healing, and horizontally scalable.",{"type":164,"level":165,"children":166},"heading",3,[167],{"type":127,"text":168},"Subject-Based Routing",{"type":124,"children":170},[171],{"type":127,"text":172},"NATS routes messages using \"subjects,\" which are hierarchical, dot-separated strings (e.g., sensors.temperature.livingroom). Clients subscribe to specific subjects or use wildcards:",{"type":138,"format":139,"children":174},[175,179],{"type":142,"children":176},[177],{"type":127,"text":178},"The asterisk (`) matches a single token at a specific level (e.g., sensors..livingroom`).",{"type":142,"children":180},[181],{"type":127,"text":182},"The greater-than symbol (>) matches one or more tokens at the end of a subject (e.g., sensors.>).",{"type":124,"children":184},[185],{"type":127,"text":186},"This subject-based routing is handled entirely in-memory by the server, enabling extremely fast routing decisions without database lookups or disk access.",{"type":164,"level":165,"children":188},[189],{"type":127,"text":190},"Clustering and Gateways",{"type":124,"children":192},[193],{"type":127,"text":194},"NATS servers can be clustered together to form a single logical mesh. Servers in a cluster automatically share subscription information, ensuring that a message published to one server is routed to subscribers connected to any other server in the cluster.",{"type":138,"format":139,"children":196},[197,201],{"type":142,"children":198},[199],{"type":127,"text":200},"Gateways: For geographically distributed deployments, NATS uses Gateways to connect distinct clusters over high-latency WAN links. Gateways optimize traffic by only forwarding messages when there is an active subscription in the remote cluster.",{"type":142,"children":202},[203],{"type":127,"text":204},"Leaf Nodes: These are lightweight NATS servers that run at the edge (e.g., on an IoT gateway or local office server) and establish a secure, outbound connection to a central NATS cluster. Leaf nodes can operate autonomously when disconnected from the main cluster and automatically synchronize messages once connectivity is restored.",{"type":164,"level":165,"children":206},[207],{"type":127,"text":208},"JetStream and Raft Consensus",{"type":124,"children":210},[211],{"type":127,"text":212},"When JetStream is enabled, NATS uses the Raft consensus algorithm to replicate stream data across a cluster. A JetStream cluster typically consists of 3 or 5 nodes to maintain a quorum. Streams can be configured to store data in-memory for maximum speed or on disk for durability. Consumers pull or push messages from these streams, with NATS tracking message acknowledgments to guarantee delivery.",{"type":164,"level":165,"children":214},[215],{"type":127,"text":216},"Security and Multi-Tenancy",{"type":124,"children":218},[219],{"type":127,"text":220},"NATS features a decentralized security model using NKEYS (Ed25519 signatures) and JWTs (JSON Web Tokens). This allows administrators to define fine-grained permissions for subjects, accounts, and users without requiring a central database lookup during connection. Multi-tenancy is built directly into the core, allowing separate \"Accounts\" to share the same physical cluster while maintaining complete cryptographic isolation of subjects.",{"id":222,"type":223,"title":224,"content":225},285,"pros","Strengths",[226,230],{"type":124,"children":227},[228],{"type":127,"text":229},"NATS offers several compelling advantages for modern software architects:",{"type":138,"format":139,"children":231},[232,236,240,244,248,252],{"type":142,"children":233},[234],{"type":127,"text":235},"Extreme Performance: Written in Go with highly optimized network polling and memory management, a single NATS server can process millions of messages per second. Latency is consistently in the microsecond range, making it one of the fastest messaging systems available.",{"type":142,"children":237},[238],{"type":127,"text":239},"Operational Simplicity: NATS is distributed as a single binary with zero external dependencies. Unlike Apache Kafka, which historically required ZooKeeper or complex KRaft configurations, or RabbitMQ with its Erlang runtime dependencies, NATS can be configured and running in seconds.",{"type":142,"children":241},[242],{"type":127,"text":243},"Flexible Topologies: With native support for clustering, WAN gateways, and leaf nodes, NATS can span from local development environments to multi-cloud networks and remote edge devices.",{"type":142,"children":245},[246],{"type":127,"text":247},"Built-in Multi-Tenancy: NATS supports \"Accounts,\" which provide strict cryptographic isolation of subjects and users within a single server or cluster. This allows different teams or clients to share the same infrastructure securely without subject collisions.",{"type":142,"children":249},[250],{"type":127,"text":251},"Unified Capabilities: By providing pub-sub, request-reply, persistent streams, key-value stores, and object storage in one tool, NATS reduces the \"tool sprawl\" common in microservice architectures.",{"type":142,"children":253},[254],{"type":127,"text":255},"Adaptive Client Libraries: NATS client libraries are designed to handle reconnection, server discovery, and buffering automatically, shielding developers from the complexities of network partitions.",{"id":257,"type":258,"title":259,"content":260},286,"cons","Limitations and Trade-offs",[261,265],{"type":124,"children":262},[263],{"type":127,"text":264},"While NATS is highly versatile, it has specific limitations that teams must consider:",{"type":138,"format":139,"children":266},[267,271,275,279,283],{"type":142,"children":268},[269],{"type":127,"text":270},"No Complex Message Transformations: Unlike enterprise service buses (ESBs) or Apache Kafka (with Kafka Streams), NATS does not perform message transformations, schema enforcement, or complex event processing (CEP) on the server. Clients must handle all payload serialization, deserialization, and transformation.",{"type":142,"children":272},[273],{"type":127,"text":274},"Subject Namespace Complexity: Because subjects are the primary routing mechanism, designing a clean, scalable subject hierarchy is critical. Poorly planned subject namespaces can lead to subscription leaks, security issues, or inefficient routing.",{"type":142,"children":276},[277],{"type":127,"text":278},"Memory Overhead under JetStream Pressure: While Core NATS has a tiny memory footprint, enabling JetStream with in-memory streams or large consumer backlogs can significantly increase memory usage. If not monitored, a slow consumer on an in-memory stream can exhaust server memory.",{"type":142,"children":280},[281],{"type":127,"text":282},"Smaller Ecosystem: Although NATS has mature client libraries for over 40 programming languages, its ecosystem of third-party connectors (e.g., database sinks, source connectors) is smaller than that of Apache Kafka or RabbitMQ. Teams may need to write custom integration code to bridge NATS with legacy databases or external SaaS platforms.",{"type":142,"children":284},[285],{"type":127,"text":286},"Strict Subject Naming Rules: Subjects in NATS are case-sensitive and cannot contain spaces or certain special characters. This requires strict governance across development teams to prevent routing mismatches.",{"id":288,"type":289,"title":290,"content":291},287,"use-cases","Suitable Use Cases",[292,296],{"type":124,"children":293},[294],{"type":127,"text":295},"NATS is exceptionally well-suited for several architectural patterns:",{"type":138,"format":139,"children":297},[298,302,306,310,314],{"type":142,"children":299},[300],{"type":127,"text":301},"Microservices Communication: NATS acts as a lightweight, resilient service mesh alternative. Its built-in request-reply pattern handles synchronous RPC calls, while pub-sub handles asynchronous event distribution.",{"type":142,"children":303},[304],{"type":127,"text":305},"Edge and IoT Telemetry: Using leaf nodes, NATS can run on remote gateways, collect telemetry data locally, and stream it back to a central cloud cluster when a connection is available. This is ideal for maritime, automotive, or industrial IoT applications.",{"type":142,"children":307},[308],{"type":127,"text":309},"Real-Time Event Streaming: Applications requiring low-latency updates, such as financial trading dashboards, live sports scores, or collaborative document editing, benefit from Core NATS' sub-millisecond delivery.",{"type":142,"children":311},[312],{"type":127,"text":313},"Distributed Configuration Management: The NATS JetStream Key-Value store is perfect for distributing dynamic configuration, feature flags, or runtime state across thousands of distributed microservices.",{"type":142,"children":315},[316],{"type":127,"text":317},"Command and Control (C2) Systems: The fast request-reply and subject-based routing make NATS ideal for sending commands to distributed fleets of devices or workers and receiving immediate status updates.",{"id":319,"type":320,"title":321,"content":322},288,"when-not-to-use","When Not to Use It",[323,327],{"type":124,"children":324},[325],{"type":127,"text":326},"Do not choose NATS if your architecture requires:",{"type":138,"format":139,"children":328},[329,333,337,341],{"type":142,"children":330},[331],{"type":127,"text":332},"Massive Analytical Data Lake Ingestion: If you need to ingest terabytes of log data per hour for long-term analytical storage and batch processing, Apache Kafka remains the industry standard due to its deep integration with the Hadoop, Spark, and Flink ecosystems.",{"type":142,"children":334},[335],{"type":127,"text":336},"Multi-Stream Transactions: NATS does not support distributed transactions across multiple streams or subjects. If your business logic requires strict ACID guarantees across different message queues, a traditional relational database or a transactional broker like RabbitMQ is more appropriate.",{"type":142,"children":338},[339],{"type":127,"text":340},"Server-Side Message Filtering and Querying: NATS routes messages based strictly on the subject string. If you need to query or filter messages based on the contents of the payload (e.g., SQL-like queries on JSON payloads inside the broker), you should look at databases or brokers that support payload indexing.",{"type":142,"children":342},[343],{"type":127,"text":344},"Heavy Payload Storage: While NATS JetStream includes an Object Store, it is designed for moderate file sizes and configuration assets. It is not a replacement for dedicated object storage solutions like AWS S3 or MinIO for storing petabytes of unstructured media files.",[346,351,356],{"id":347,"label":348,"url":349,"kind":350},138,"NATS Official Website","https://nats.io/","official",{"id":352,"label":353,"url":354,"kind":355},139,"NATS Documentation","https://docs.nats.io/","docs",{"id":357,"label":358,"url":359,"kind":360},140,"NATS GitHub Repository","https://github.com/nats-io/nats-server","repo",[],[363,367,371],{"id":364,"question":365,"answer":366},142,"What is the difference between Core NATS and JetStream?","Core NATS is an in-memory, fire-and-forget messaging system with at-most-once delivery guarantees. JetStream is a built-in persistence engine for NATS that adds at-least-once or exactly-once delivery, message streaming, deduplication, and historical replay.",{"id":368,"question":369,"answer":370},143,"Does NATS require external storage for persistence?","No. NATS JetStream handles persistence natively. It can store stream data either in-memory or directly on the local filesystem of the server nodes, using Raft consensus for replication across clusters.",{"id":372,"question":373,"answer":374},144,"Can NATS be used as a Key-Value store?","Yes. NATS JetStream provides a built-in Key-Value store abstraction layer built on top of its persistent streams, allowing you to get, put, and watch keys with microsecond latencies.",{"pagination":376},{"page":110,"pageSize":377,"pageCount":110,"total":110},25]