Overview
What's Included
- NATS Server with JetStream enabled
- Persistent message storage
- TLS encryption
- Authentication enabled
- Monitoring endpoints
- Cluster-ready configuration
- Separate data volume
Step-by-Step Guide
1
Launch the AMI
Find "NATS JetStream FlowOps" on AWS Marketplace and launch.
# Recommended instance types:
# t3.medium (4GB) - Development
# m5.large (8GB) - Production
# m5.xlarge (16GB) - High throughput
# NATS is incredibly lightweight!
2
Connect to NATS
Get credentials and test the connection.
ssh -i your-key.pem ubuntu@your-instance-ip
sudo cat /opt/flowops/credentials.txt
# NATS endpoints:
# Client: nats://your-ip:4222
# Monitoring: http://your-ip:8222
# Test with nats CLI
nats server info
3
Create a Stream
Set up JetStream for persistent messaging.
# Using NATS CLI
nats stream add ORDERS \
--subjects "orders.*" \
--retention limits \
--max-msgs 1000000 \
--max-bytes 1GB \
--max-age 24h
# Create a consumer
nats consumer add ORDERS order-processor \
--filter "orders.created" \
--ack explicit \
--deliver all \
--replay instant
# View stream info
nats stream info ORDERS
4
Publish and Subscribe (Python)
Use NATS in your application with the Python client.
# pip install nats-py
import asyncio
import nats
from nats.js.api import StreamConfig
async def main():
# Connect to NATS
nc = await nats.connect(
servers=["nats://your-instance-ip:4222"],
user="user",
password="your-password"
)
js = nc.jetstream()
# Publish messages
for i in range(10):
await js.publish(
"orders.created",
f'{{"order_id": "ORDER-{i}", "amount": {i * 10}}}'.encode()
)
print(f"Published order {i}")
# Subscribe and process
sub = await js.pull_subscribe("orders.created", "order-processor")
while True:
try:
msgs = await sub.fetch(10, timeout=5)
for msg in msgs:
print(f"Received: {msg.data.decode()}")
await msg.ack()
except asyncio.TimeoutError:
break
await nc.close()
asyncio.run(main())
Comparison
| Feature | NATS JetStream | Kafka | RabbitMQ |
|---|---|---|---|
| Latency | Sub-ms | Low ms | Low ms |
| Complexity | Simple | Complex | Medium |
| Persistence | JetStream | Yes | Yes |
| Resource Usage | Very light | Heavy | Medium |
| Clustering | Built-in | ZooKeeper/KRaft | Erlang |
Use Cases
- Microservices communication
- IoT device messaging
- Real-time notifications
- Event sourcing
- Log aggregation
- Command and control systems
Pricing
Our AMIs are available on AWS Marketplace with simple hourly pricing:
- Software: $0.10-0.15/hour (varies by product)
- EC2: Standard AWS pricing for your chosen instance
- Support: 24/7 included with guaranteed 24-hour response
Need Help?
Our UK-based support team is here to help you get the most out of your deployment. Email us at support@flowopsconsulting.co.uk for any questions.
Comments