Scrivio Interview library
ScenarioAdvanced7 min read · updated 12 November 2026

A team wants to use Redis as the primary store for shopping carts and order drafts to get low latency, with no relational database behind it. How do you evaluate the proposal and what conditions would you set?

We evaluate the proposal by what it would cost to lose or be unable to query this data. Redis replication is asynchronous and AOF everysec can lose about a second, so a failover can drop acknowledged writes; it has no secondary indexes or joins without extra structures, so support and reporting need another path; and the whole dataset must fit in RAM with noeviction so nothing is silently dropped. If approved, the conditions are AOF with replicas, WAIT for critical writes, tested backups, an export stream to an analytical store and TTLs for abandoned carts, but often the better design keeps orders in a relational database and uses Redis only for carts that can be rebuilt.

Why this question is asked

Low latency is a real benefit, and a team that has struggled with a slow cart page has good reasons to look at Redis. But removing the relational database changes what the system promises: that a customer's draft order survives a failover, that support can find it, that finance can report on it. Interviewers ask this scenario to see whether a senior engineer can evaluate a proposal fairly, put numbers on the risks, and either set conditions that make it safe or propose a better split. In this answer, we will look at what the team wants and why, evaluate durability, the data model and memory cost, set the conditions for approval, and compare it with the usual alternative.

1What the Team Wants and Why It Is Attractive

Carts and order drafts are read and written on almost every page of a shop: add an item, change a quantity, show the mini-cart in the header. A Redis hash per cart answers those in well under a millisecond, with no schema, no ORM and no connection pool contention. For a team whose relational cart table is a hotspot, that is an appealing simplification.

So we should not dismiss the idea. The question is what the business loses if a cart or an order draft disappears or cannot be found, and whether Redis can be configured to make that loss acceptable.

Text
# A cart as a Redis hash: one field per product, quantity as the value
HSET cart:u-981 p-17 2 p-42 1 # (integer) 2
HINCRBY cart:u-981 p-17 1 # (integer) 3
HGETALL cart:u-981 # p-17 3, p-42 1
EXPIRE cart:u-981 2592000 # abandoned carts disappear after 30 days

2Durability: What Can Be Lost

Redis acknowledges a write as soon as it is in memory on the primary. With AOF and appendfsync everysec, it reaches the disk within about a second, so a crash of the machine can lose roughly the last second of writes. More important, replication to replicas is asynchronous. If the primary fails and a replica is promoted, any writes it had not yet received are gone, even though customers saw them succeed.

We put numbers on that. Suppose the shop handles 300 cart writes per second at peak and a failover loses one to two seconds of them: up to 600 customers see an item vanish from their cart. For carts that is an annoyance. For an order draft holding a delivery address, a negotiated price or a payment intent, it can mean a lost sale, a duplicate charge after a retry, or a support case.

Step throughAn acknowledged write lost in failover
Shop serviceRedis primaryRedis replica
HSET draft:7731 address ...
OK (acknowledged)
replicate (async, not yet sent)
primary crashes
promoted to primary without draft:7731 change
HGETALL draft:7731
old state: the address is gone

7 messages in order. Play them, or step through them one at a time.

Persistence on the old primary cannot help: the new primary never had the write.

3Data Model Limits: Who Else Needs This Data

Redis answers questions we prepared for: give me cart u-981. It has no secondary indexes or joins of its own. A support agent asking which drafts contain product p-42, or finance asking how many drafts over 500 euros were abandoned last week, has no way to ask unless we built and maintained extra structures, such as a set of draft ids per product, for every question in advance. Search modules can add indexes in some distributions, but they bring their own memory cost and distribution dependency.

So we must list the readers besides the shop page: customer support, fraud checks, analytics, finance, GDPR data requests. Each needs a path to the data. If the only answer is a script that SCANs millions of keys, the proposal is incomplete.

4Memory and Capacity

Everything lives in RAM, so we estimate the size. Ten million active carts averaging 1 KB with overhead is about 10 GB, plus order drafts, plus growth of perhaps 40 percent a year, plus headroom for forks during persistence. That is affordable, but it must be planned: instance sizes, replicas, and, if it grows, sharding by cart id in a cluster.

And the eviction policy must be noeviction. With an allkeys policy, a full instance would silently delete customers' carts to make room. With noeviction, a full instance rejects writes, which is visible and alertable; we alert at 70 percent of maxmemory so it never gets there. TTLs on abandoned carts keep the dataset bounded.

5Conditions If We Approve

If the business accepts the quantified risk, for carts at least, we approve with conditions written into the decision record. AOF with everysec and at least one replica, preferably two, with automatic failover through Sentinel or a managed service. For critical writes such as converting a draft into an order, the service calls WAIT so the write is acknowledged by a replica before the user sees success; this narrows the loss window but does not remove it. Backups of RDB files from a replica to object storage, with a restore test every quarter that measures how long recovery takes.

Next, an export stream: every cart and draft change is also published, through a stream or an event to Kafka, into an analytical store where support and finance can query it. Clear TTLs for abandoned carts, maxmemory-policy noeviction with memory alerts, and an agreed behaviour when data is lost, such as rebuilding a cart from the export stream or asking the customer to re-add items.

Text
HSET draft:7731 address "12 Rua Azul" status CONFIRMING
WAIT 1 100 # (integer) 1: one replica has it, or 0 after 100 ms
# if WAIT returns 0, treat the confirmation as not yet safe and retry or warn

6The Usually Better Design

Often the stronger design separates the two kinds of data. Carts are rebuildable and tolerate small loss, so they can live in Redis, optionally with a periodic snapshot to the database for logged-in users. Orders, and drafts once they hold payment or address commitments, go into a relational database, where commits are durable, constraints protect the data, and support and finance can query it with SQL. The cart page stays fast because it reads Redis; the checkout stays safe because it writes the database.

If the team really needs a key-value store as the primary store for drafts, a durable key-value database with synchronous replication is a better fit than Redis, because it is built for that guarantee.

Options for carts and order drafts
DesignLatencyLoss on failoverQueries for support
Redis onlysub-msabout 1-2 s of writesonly prepared structures
Redis carts, SQL orderssub-ms carts, ms orderscarts only, rebuildableSQL on orders
SQL only, tuneda few msnone after commitSQL on everything
Durable key-value storemsnone after quorum writelimited, plus export

7Follow-up questions

What does WAIT guarantee and what does it not?

WAIT numreplicas timeout blocks the client until that many replicas have acknowledged receiving all its previous writes, or the timeout passes, and returns how many did. It guarantees that the write existed on those replicas at that moment. It does not guarantee the write is on disk there (WAITAOF in newer versions addresses that), it does not roll back if fewer replicas confirm, and a failover may still promote a replica that missed it, so it reduces loss without making Redis strongly consistent.

Would Redis Cluster change the evaluation?

It helps with capacity, since carts can be sharded across nodes by key, but it does not change durability: each shard still replicates asynchronously, and failover of a shard can lose its latest writes. It also adds the constraint that multi-key operations must stay within one hash slot.

How would we migrate if we later want orders in a database?

Write drafts to both stores for a period, reading from Redis, then backfill the database from Redis, compare them with a reconciliation job, and switch reads. Because orders are created from drafts at checkout, the cleanest cut-over is to make checkout write the order into the database first and treat Redis as the cache of the draft.

8Conclusion

In this answer, we evaluated using Redis as the only store for carts and order drafts. Asynchronous replication and AOF everysec mean a failover can lose about a second or two of acknowledged writes, the data model gives support and reporting no query path without extra structures, and the full dataset must fit in RAM with noeviction. If approved, we require AOF with replicas, WAIT for critical writes, tested backups, an export stream to an analytical store and TTLs for abandoned carts; often the better design keeps orders in a relational database and uses Redis for rebuildable carts.

What to say in the interviewAbout 80 seconds aloud

Open with

I would take the latency goal seriously but evaluate it by what we lose. First, durability: Redis acknowledges writes from memory, AOF everysec can lose about a second on a crash, and replication is asynchronous, so a failover can drop writes customers already saw succeed.

Then, if they want more

I would quantify it: at 300 writes a second, a two-second loss affects about 600 carts, and for drafts with addresses or payment intents that means lost sales or support cases. Second, the data model: there are no secondary indexes or joins without building extra structures in advance, so support, fraud, finance and data requests need another path.

Third, memory: the whole dataset plus growth and fork headroom must fit in RAM, and the policy must be noeviction so carts are never silently evicted, with alerts well before maxmemory.

If the business accepts the risk, my conditions are AOF everysec with two replicas and automatic failover, WAIT on critical writes like confirming a draft, regular backups with restore tests, an export stream into an analytical store for queries, and TTLs on abandoned carts.

But I would usually propose a split: carts in Redis because they can be rebuilt, orders and committed drafts in a relational database, or a durable key-value store if they really want key-value.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Redis documentation
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "A team wants to use Redis as the primary store for shopping carts and order drafts to...": https://scrivio-interview-library.netlify.app/databases/redis/cab9d6276f/