Exploring Messaging and Streaming Technologies Part7: NATS JetStream

SHARE

NatS JetStream-1

In Francine Anestis ongoing exploration of Messaging and Streaming technologies, she immerses herself in the realm of NATS JetStream. Unpacking the platform's key features, architecture, versatile applications, strengths, weaknesses, cost considerations, and overall level of development, she provides invaluable perspectives for her readers.

NATS JetStream (evolved version of NATS Streaming) is an advanced messaging and streaming technology built on top of the core NATS messaging system. It enhances the traditional capabilities of NATS by adding persistent storage, message replay, and other advanced streaming features. It is built to provide scalability, reliability, and simplicity, making it suitable for a wide range of applications.

Key Features

  • High Performance: Optimized for low latency and high throughput (for throughtput of 1B/s the latency is ~2 – 5 msec for non-persistent messages and ~10 – 20 msec for persistent messages).

  • Persistence: Provides durable message storage with options for message replay.

  • Streaming Capabilities: Supports advanced features such as message ordering, at-least-once and exactly-once delivery semantics, and durable subscriptions.

  • Scalability: Designed to manually scale horizontally through clustering.

  • Fault Tolerance and High Availability: Built-in support for high availability and fault tolerance.

  • Security: Supports TLS for secure communication and fine-grained access control.

  • Simplicity: Easy to set up, use, and manage with a straightforward API and tooling.

  • Multi-Tenancy: Supports isolated streams and resources for different tenants or applications.

  • NATS Protocol: The primary protocol used by NATS and NATS JetStream. It is a lightweight, high-performance messaging protocol designed for low latency and high throughput. It also supports integration with other protocols (e.g., MQTT) through connectors and bridges (non-native protocols).

  • Pub/Sub Messaging Model: NATS JetStream uses the publish/subscribe (pub/sub) messaging model. This model allows messages to be published to subjects (streams), and multiple subscribers can listen to these subjects (streams) to receive the messages.

Architecture

JetStream Architecture-1-1

  • Core NATS Server: The foundational component that manages connections, routing, and basic messaging.

  • Publishers: Applications or services that connect to NATS core to publish the messages.

  • JetStream Layer: Extends the core server with capabilities for message persistence, stream management, and replay.

  • Streams: Logical collections of messages with configurations for retention, replication, and storage.

  • Consumers: Applications or services that listens the messages from streams with configurations for delivery semantics and processing modes.

  • Message Storage: Persistent storage backends (e.g., file system, cloud storage) for durable message storage.

  • Sharding: You can manually shard data across multiple streams to distribute the load. Each shard can be a separate stream, and consumers can be configured to consume from specific shards based on your application's logic.

  • Queue Groups: Consumers can be grouped into queue groups, where each message is delivered to only one member of the group. This allows for load balancing among consumers.

  • Clustered Deployment: JetStream can be deployed in a clustered configuration, where multiple JetStream servers work together to provide high availability and scalability. This setup can handle large volumes of messages and distribute the load across the cluster.

Use Cases

  • Microservices Communication:

    • Enabling efficient, reliable, and persistent communication between microservices.

  • IoT Data Streaming:

    • Collecting and processing data streams from IoT devices in real-time.

  • Real-Time Analytics:

    • Streaming data into analytics systems for real-time processing and insights.

  • Event-Driven Architectures:

    • Building applications that react to events as they occur, with guaranteed message delivery.

  • Financial Services:

    • Low-latency messaging for trading systems, fraud detection, and other financial applications.

Strenghts

  • Performance: Offers low latency and high throughput, making it suitable for time-sensitive applications.

  • Simplicity: Easy to deploy, configure, and use with a developer-friendly API.

  • Flexibility: Supports a wide range of messaging and streaming patterns and use cases.

  • Scalability: Horizontally scalable to handle increasing loads and ensure high availability.

  • Security: Provides robust security features to protect communication and data.

  • Persistence and Replay: Supports durable storage and message replay, ensuring reliable message delivery.

Weaknesses

  • Operational Complexity: Managing clusters and ensuring high availability can add complexity to operations.

  • Learning Curve: Some advanced features may require a learning curve for new users.

  • Community and Ecosystem: The community and ecosystem might be smaller compared to more established platforms like Kafka.

  • Feature Parity: While it offers many advanced features, it might not match the breadth of features available in more mature streaming platforms like Kafka.

Cost

NATS JetStream is open-source and free to use. Costs are primarily associated with the infrastructure required to deploy, manage, and run NATS JetStream, including:

  • Compute Resources: Servers, whether on-premises or cloud-based, to run NATS JetStream servers.
  • Storage: Persistent storage for durable message storage.
  • Operational Costs: Costs related to managing and maintaining the NATS JetStream deployment, including monitoring, scaling, and securing the system.

Maturity Level

Emerging (2020): NATS JetStream is a relatively new addition to the NATS ecosystem but builds on the mature and stable foundation of NATS (2010). It has seen rapid development and adoption, reflecting a robust and growing community and active support from the developers.

Conclusion

NATS JetStream is a powerful and flexible messaging and streaming system that extends the capabilities of the core NATS messaging platform. It offers high performance, scalability, and advanced streaming features such as persistence and message replay, making it suitable for real-time data streaming applications. While it may not have all the advanced features of more mature streaming platforms like Apache Kafka, it is an excellent choice for applications requiring low-latency, high-throughput messaging with a simple and scalable architecture. For organizations looking to implement real-time data streaming with minimal complexity, NATS JetStream is a compelling option.

Need help with your Stream Processing project?

 

Ready to set off on a BIG journey?

The top notch technologies we use set us apart from other consultancies