Posts

Showing posts from February, 2026

Redis Advanced Architecture

  Redis Streams vs Pub/Sub (Advanced Architecture) When designing scalable systems using Redis , one of the most common architectural decisions is: Should I use Pub/Sub or Streams ? 1️⃣ Redis Pub/Sub – Fire & Forget Messaging How It Works Publisher sends message to channel Redis pushes message instantly to subscribers No storage No acknowledgment SUBSCRIBE notifications PUBLISH notifications "New Order Created" Characteristics Real-time delivery No persistence No retry No message history No consumer tracking Best For ✔ Live chat ✔ Real-time dashboards ✔ WebSocket notifications ✔ Lightweight microservice communication 2️⃣ Redis Streams – Persistent Event Log Redis Streams (introduced in Redis 5) behave like a lightweight event streaming platform. XADD orders * user_id 101 product "Laptop" XREAD STREAMS orders 0 Key Features Persistent message log Consumer groups Acknowledgment support Message replay Mes...

Redis Questions and Answers

  1. What is Redis and why is it fast? Redis is an in-memory key-value data store that supports multiple data structures like strings, hashes, lists, sets, and sorted sets. Why fast? In-memory storage (RAM) Single-threaded event loop (no locking overhead) Efficient C implementation O(1) operations for most commands 2. What are Redis data types? String List Set Sorted Set Hash Stream Bitmap HyperLogLog 3. What is the difference between RDB and AOF? Feature RDB      AOF Type                     Snapshot                     Append log Performance                     Faster                   Slightly slower Data Safety                    ...

Redis

  Redis Series – The Ultimate Guide for Backend Developers As a Python Backend Developer , especially if you’re working with Django and scalable APIs, understanding Redis is a game-changer. What is Redis? Redis (Remote Dictionary Server) is an open-source, in-memory data structure store used as: 🔹 Cache 🔹 Database 🔹 Message Broker 🔹 Queue System Unlike traditional databases, Redis stores data in memory (RAM) , making it extremely fast. Why Redis is So Fast? In-memory storage (no disk I/O for reads) Single-threaded event loop (no locking overhead) Optimized C implementation Efficient data structures Redis operations are typically executed in microseconds . Redis Data Structures Redis is not just a key-value store. It supports powerful data structures: Data Type    Description           Example Use Case String                Simple key-value    ...

Celery Questions and Answers

  Q1: What is a message broker? A system that passes messages between producer and worker (Redis, RabbitMQ). Q2: Difference between synchronous and asynchronous? Synchronous blocks execution. Asynchronous runs in background. Q3: How does Celery scale? By adding more worker processes or containers. Q4: What happens if worker crashes? Task remains in broker queue and can be retried. Q5: Difference between Celery and cron? Cron schedules OS-level jobs. Celery manages distributed background jobs. 1️⃣ What is Celery? Celery is a distributed task queue used to run asynchronous and background tasks in Python applications. It helps execute time-consuming operations outside the request-response cycle. 2️⃣ Why do we need Celery in Django? In Django : Without Celery: API waits until email/report/API call finishes Slow response time With Celery: Tasks run in background Faster API response Better scalability 3️⃣ What is a Message Broker? A message broker is ...