A team uses Redis as the primary store for user carts with no persistence. Is that a problem?
BeginnerScenarioData and databases
Answer
Situation read → Yes. A restart, failover or eviction loses every cart, and with maxmemory-policy allkeys-lru Redis can silently evict data when memory fills.
What I'd do →
- Decide whether losing carts is acceptable. If not, Redis can't be the only copy as configured.
- Short term: enable persistence (AOF with
appendfsync everysec) or use ElastiCache with Multi-AZ and backups, and setmaxmemory-policy noevictionso it errors instead of dropping data. - Better: keep carts in a durable store (DynamoDB or Postgres) and use Redis as a cache in front.
- Alert on
evicted_keysand memory use.
redis-cli INFO stats | grep evicted_keys
redis-cli CONFIG GET maxmemory-policy
Why → A cache is allowed to lose data; a system of record isn't.
Interview tip → Ask "what happens if this data disappears?" before choosing where it lives.
More on Data and databases
A release needs to rename a column that the running app reads and writes. How do you do it with zero downtime?IntermediateHow do you prove your database backups actually work?IntermediateDesign backups for an RDS PostgreSQL database with RPO of 5 minutes and RTO of 1 hour, including a region failure.AdvancedYour migrations run in an init container and two pods ran them at the same time during a deploy, leaving the schema half-applied. How do you fix the approach?IntermediateUpgrade RDS PostgreSQL from 13 to 17 with minimal downtime. How?AdvancedYou need to add an index and a column to a 500-million-row table that's written to constantly. How do you avoid locking it?Advanced