Blog/Redis vs PostgreSQL vs Kafka
System Design & Architecture Decisions August 31, 2026 14 min read

Redis vs PostgreSQL vs Kafka: Choosing the Right Tool for the Job

Three technologies. Three fundamentally different jobs. How I think about choosing PostgreSQL, Redis, and Kafka when designing distributed backend systems.

Tamirat Fereja, Backend Systems Engineer
Tamirat Fereja
Backend Systems Engineer | Specializing in NestJS, Kafka & PostgreSQL

Core Insight

  • PostgreSQL → “What is true?” (source of truth)
  • Redis → “What do I need quickly?” (performance layer)
  • Kafka → “What happened?” (event stream)
  • Never treat them as interchangeable databases

A common architectural mistake is asking:

“Should I use Redis, PostgreSQL, or Kafka?”

That question is incomplete. These technologies are not direct replacements for one another. They solve different classes of problems.

A better question is:

What problem am I solving, what guarantees do I need, and what kind of data am I dealing with?
Interactive System Layer Visualizer
Application Layer
PostgreSQL
Source of Truth
Redis
Fast Access
Kafka
Event Stream

1. Start With the Problem, Not the Technology

Before choosing a database, cache, or message broker, I ask:

Interactive Requirement Filter

Select your architectural requirement to see the recommended tool in real time:

  • Is this authoritative business data?
  • Does it need transactions?
  • Does it need extremely fast temporary access?
  • Do multiple services need to react to the change?
  • Should the data survive application restarts?
  • Do consumers need to process events independently?
  • Do I need ordering or replay?
Simplified Decision Model
Authoritative state?PostgreSQL
Temporary / fast-access state?Redis
Something happened → other systems react?Kafka

2. PostgreSQL: The Source of Truth

I generally think of PostgreSQL as the system that answers:

What is the current authoritative state of the business?
UsersEnrollmentsCoursesPaymentsOrdersCertificatesCohortsPermissionsSchedules

These entities require strong consistency and durable storage. If the application restarts, Redis disappears, or Kafka is temporarily unavailable, the enrollment must still exist. That is why PostgreSQL belongs at the center of many transactional systems.

3. PostgreSQL and Transactions

One of PostgreSQL’s biggest advantages is transactional correctness. Consider cohort enrollment with capacity = 30 and available seats = 1:

BEGIN
↓ SELECT … FOR UPDATE
↓ Check capacity
↓ Create enrollment
↓ Decrease available seats
COMMIT

The database is enforcing the critical state transition. This is fundamentally different from caching or event streaming.

4. PostgreSQL Is More Than a CRUD Database

Transactions
Row-level locking
Constraints
Indexes
Foreign keys
Window functions
CTEs
JSON/JSONB
Full-text search
Materialized views
Partitioning
Replication

5. Redis: Optimize Access to State

Redis answers a different question:

How can I access frequently needed data extremely quickly?
CachingSessionsRate limitingCountersTemporary stateDistributed locksShort-lived data
Without cache
API → PostgreSQL
Complex query ≈ 100ms
With Redis
API → Redis
1ms-ish access

6. Redis Should Not Automatically Become Your Database

Because Redis is fast, it can be tempting to store everything there. Ask:

What happens if Redis is unavailable?
Safe
Performance degrades → fall back to PostgreSQL
Dangerous
Business data is lost

A safer pattern is: PostgreSQL as Source of Truth, Redis as Performance Layer.

7. The Cache-Aside Pattern

Request → Check Redis
Hit
→ Return
Miss
→ Query PostgreSQL
→ Store in Redis
→ Return
const cached = await redis.get(key);
if (cached) return JSON.parse(cached);

const data = await repository.find(...);
await redis.set(key, JSON.stringify(data), 'EX', 300);
return data;

8. Redis Is Also Useful for Rate Limiting

A Redis counter can track request activity for limits such as 100 requests / minute:

Request → Redis INCR → Check limit
AllowReject

9. Kafka: Moving Events Through the System

Kafka answers:

How can systems communicate through durable streams of events?
Direct Coupling
Enrollment Service
├── Calendar
├── Notification
├── Analytics
└── Certificate
Via Kafka
Enrollment Service
↓
Kafka
├── Calendar
├── Notification
└── Analytics

10. Kafka Is Not a Database Replacement

Kafka stores messages durably, but that does not mean it should become your primary business database. PostgreSQL answers “Is this student enrolled?” Kafka answers “What happened and who should react?”

11. State vs Events

PostgreSQL
What is true now?
Redis
What can I access quickly?
Kafka
What happened?

12. Example: Student Enrollment

Step 1 — PostgreSQL
Enrollment becomes authoritative state
Step 2 — Redis
Frequently accessed cohort info may be cached
Step 3 — Kafka
ENROLLMENT_CREATED event triggers downstream services

13. Another Example: Certificate Generation

PostgreSQL → Certificate metadata
↓
Kafka → CERTIFICATE_GENERATION_REQUESTED
↓
Certificate Worker → Puppeteer → File Service → Object Storage
(+ optional Redis for progress / rate limits)

14–15. What Happens If Redis or Kafka Goes Down?

Redis Down
If used as cache → fall back to PostgreSQL. Performance degrades, correctness remains. Good failure mode.
Kafka Down
Core enrollment still succeeds in PostgreSQL. Downstream processing is delayed until recovery. Core transaction stays valid.

16. Don’t Create Distributed Coupling by Accident

Poor
API depends on PostgreSQL + Redis + Kafka + Calendar + Notification + File Service in one request
Better
Core path: API → PostgreSQL. Then event → Kafka → async consumers

17. Consistency vs Performance vs Decoupling

ConcernPostgreSQLRedisKafka
Durable business statePrimarySecondary / OptionalEvent log durability
Primary StrengthACID Transactions & ConsistencySub-millisecond SpeedHigh Throughput Event Streaming
Key Use CaseSource of Truth DataCaching & Rate LimitingDecoupled Asynchronous Processing
Failure ImpactHigh (Service Downtime)Medium (Latency Spikes)Medium (Delayed Processing)