Introduction
Imagine you’re building a food delivery app like Talabat or Zomato. When a customer places an order, they want instant updates:
- ✅ Order confirmed
- 👨🍳 Food is being prepared
- 🙵 Delivery on the way
- 📦 Delivered
How do you make this real-time experience possible?
The answer: event streaming, and one of the best tools for that is Redpanda — a fast, Kafka-compatible streaming platform with no Java dependencies and a simpler developer experience.
In this tutorial, we’ll build a real-time order tracking system using Redpanda.
🪰 What You’ll Need
- Docker installed
- Python 3.8+ installed
kafka-pythonorconfluent-kafka(pip install kafka-python)- Basic Python knowledge
🛠️ Step 1: Run Redpanda Locally (via Docker)
Let’s spin up Redpanda with a single command:
docker run -d --pull=always --name=redpanda \
-p 9092:9092 -p 9644:9644 \
docker.redpanda.com/redpandadata/redpanda:latest \
redpanda start --overprovisioned --smp 1 --memory 1G --reserve-memory 0M \
--node-id 0 --check=false --kafka-addr PLAINTEXT://0.0.0.0:9092
🔍 Ports:
9092= Kafka API (for producers/consumers)9644= Redpanda Admin API
📁 Step 2: Define the Use Case
Let’s simulate this real-life order journey:
| Step | Status Event |
|---|---|
| 1 | Order Placed |
| 2 | Preparing Food |
| 3 | Out for Delivery |
| 4 | Delivered |
Each event will be sent as a message to Redpanda, and the frontend can subscribe in real-time.
📨 Step 3: Create a Topic for Orders
Use Python to create a topic called order-status:
from kafka.admin import KafkaAdminClient, NewTopic
admin = KafkaAdminClient(bootstrap_servers="localhost:9092")
topic = NewTopic(name="order-status", num_partitions=1, replication_factor=1)
admin.create_topics([topic])
👨🍳 Step 4: Simulate Order Status Updates (Producer)
from kafka import KafkaProducer
import json, time
producer = KafkaProducer(
bootstrap_servers='localhost:9092',
value_serializer=lambda v: json.dumps(v).encode('utf-8')
)
order_id = "ORDER123"
status_updates = [
{"order_id": order_id, "status": "Order Placed"},
{"order_id": order_id, "status": "Preparing Food"},
{"order_id": order_id, "status": "Out for Delivery"},
{"order_id": order_id, "status": "Delivered"}
]
for update in status_updates:
producer.send('order-status', update)
print(f"Sent update: {update}")
time.sleep(2) # simulate delay
producer.flush()
📬 Step 5: Real-Time Order Tracker (Consumer)
from kafka import KafkaConsumer
import json
consumer = KafkaConsumer(
'order-status',
bootstrap_servers='localhost:9092',
auto_offset_reset='earliest',
group_id='tracker-service',
value_deserializer=lambda v: json.loads(v.decode('utf-8'))
)
print("Listening for order updates...\n")
for message in consumer:
update = message.value
print(f"Order {update['order_id']} - Status: {update['status']}")
🖥️ What This Looks Like in Real Life
👨💻 Backend (Producer):
Keeps sending order updates to Redpanda.
📱 Frontend (Consumer):
Subscribes to updates and instantly shows users when the rider is nearby.
You can plug the consumer into a WebSocket or REST API to stream updates to a frontend or mobile app.
📈 Why Redpanda?
- ⚡ Blazing-fast performance
- 🧹 Kafka-compatible (reuse existing tools)
- 🩶 No JVM needed — lightweight and easy to run
- 🛠️ Built-in CLI and monitoring tools
✅ Next Steps
- Add multiple topics (e.g.
order-payments,user-feedback) - Connect Redpanda to a frontend via WebSockets
- Deploy Redpanda on Kubernetes or Redpanda Cloud
- Monitor your streams with Redpanda Console
💬 Final Thoughts
Redpanda makes it easier than ever to build real-time systems. Whether you’re handling food orders, stock prices, or IoT sensors — streaming is the future, and Redpanda helps you get there faster.
👋 Stay Connected
Want help setting up Redpanda for your own use case? Reach out or comment below!
