Overview
JetStream is NATS’s built-in persistence layer providing streaming, message replay, and exactly-once delivery semantics. These options control JetStream’s behavior, storage limits, and performance characteristics.Command Line Flags
Enable JetStream functionality.
Directory for JetStream storage files. If not specified, a temporary directory will be used.
Configuration File Options
Enabling JetStream
Enable JetStream in the configuration file.
Storage Configuration
Path to directory where JetStream will store data.The directory will be created if it doesn’t exist. Ensure the NATS server has write permissions.
Maximum memory storage in bytes for memory-based streams. Default is 75% of available memory.
Maximum file storage in bytes for file-based streams. Default is calculated based on available disk space.
Domain Configuration
JetStream domain name for multi-tenancy and organizational separation.Domains allow logical separation of JetStream resources across the same NATS infrastructure.
Sync and Performance
Interval for syncing data to disk (fsync). More frequent syncs increase durability but reduce performance.
Sync to disk after every write. Maximizes durability but significantly impacts performance.
Allow compression of stored data.
Unique tag for this JetStream instance. Useful for identifying specific servers in clusters.
Advanced Limits
Maximum bytes for catching up consumers in clustered JetStream.
Server-wide limits for JetStream operations.
Configuration Examples
Basic JetStream Setup
JetStream with Custom Sync
High Durability Configuration
Multi-Domain Setup
Clustered JetStream
Performance Optimized
Storage Types
JetStream supports two storage types per stream:File Storage
Persistent storage on disk. Suitable for:- Long-term message retention
- Large message volumes
- Durability requirements
- Message replay over extended periods
Memory Storage
In-memory storage. Suitable for:- High-performance requirements
- Temporary data
- Lower latency needs
- Smaller message volumes
Monitoring JetStream
Server Status
Check JetStream status via monitoring endpoint:Account Statistics
View account-level JetStream usage:Storage Usage
Monitor storage consumption:Best Practices
- Storage Location: Use fast SSDs for
store_dirto improve performance - Capacity Planning: Monitor storage usage and set appropriate
max_file_storelimits - Memory Limits: Set
max_memory_storeto prevent OOM errors - Sync Strategy: Balance
sync_intervalbetween durability and performance needs - Clustering: Use odd numbers of servers (3, 5) for JetStream clusters
- Backup: Regularly backup the
store_dirdirectory - Domains: Use domains to organize multi-tenant deployments
- Monitoring: Monitor JetStream metrics via
/jszendpoint - Disk Space: Ensure sufficient disk space (2-3x
max_file_store) - Permissions: Verify NATS process has read/write access to
store_dir
Limits and Quotas
JetStream enforces several limits:- Max Memory: Total memory for memory-backed streams
- Max Storage: Total disk space for file-backed streams
- Max Streams: Number of streams per account (configurable)
- Max Consumers: Number of consumers per stream (configurable)
- Max Message Size: Individual message size limit
Troubleshooting
Storage Issues
Performance Issues
- Increase
sync_intervalfor higher throughput - Use SSDs for
store_dir - Consider memory-backed streams for hot data
- Enable compression for large messages
Cluster Issues
- Verify all cluster members have JetStream enabled
- Check that
store_diris unique per server - Monitor
/jszfor cluster state - Ensure cluster connectivity via
/routez
Related Configuration
Server Options
Core server configuration
Cluster Options
Cluster JetStream for HA
TLS Options
Secure JetStream with TLS