Video in progress

A team wants to make Redis the primary (only) database in a new service. When do you agree, and when do you object?

I agree if the business can tolerate losing a little data, the volume fits in RAM and access is by key. I object if money, legal records, complex queries or reporting are involved: asynchronous replication, memory cost and query capabilities don't fit that.

📖 Answer

I start with three questions.

  1. What happens if the last 1 second of writes is lost? With appendfsync everysec and asynchronous replication, such a loss on failover is real. Sessions, rate limit counters, a real-time leaderboard, a temporary cart: tolerable. Payments, balances, orders: not.

  2. How is the data queried? Redis is excellent by key. For a query like "customers in Tashkent who ordered more than 500 thousand soums in the last 30 days", you'd have to build secondary indexes by hand. Every new business question means a new index and a new migration. There is the Redis Query Engine (formerly RediSearch), but that's one more thing for the team to learn, and it doesn't fully replace SQL.

  3. Growth in volume and cost: if the dataset goes from 50 GB to 2 TB in 3 years, keeping all of it in RAM (in three copies with replicas) costs tens of times more than a DB on disk.

The cases where I agree:

  • temporary state (where a TTL is natural): sessions, OTP codes, idempotency keys for a short period;
  • derived data: leaderboards and counters that can be rebuilt from somewhere else;
  • real-time things that need very low latency and where a loss does little harm.

If Redis is needed anyway, I set conditions: AOF + RDB, min-replicas-to-write, regular backups and testing the restore, memory monitoring and noeviction. And a clearly written decision: how much data we're ready to lose (the RPO).

We often arrive at a compromise: the source of truth is PostgreSQL, and Redis is a fast layer in front of it, or a materialized view filled through CDC. In practice this gives the team both Redis's speed and the DB's reliability.