Quick revision
The short answer
I would not make write-behind the default. It moves the system of record into the cache for the length of the delay, trading durability, consistency for other readers and auditability for latency, which suits counters, presence and preferences but not money, orders or inventory. I would allow it by data class, first check whether a tuned database write or a durable log append already meets 10 ms, and where it is allowed require a bounded queue, per-key coalescing, versioned writes, lag monitoring and a loss window the product owner has agreed to.
What to remember
In this answer, we saw that write-behind makes the cache the only holder of the truth during the delay, trading durability, consistency and auditability for latency. We would first check whether a tuned database write or a durable log append meets the 10 ms target, allow write-behind only for data like counters, presence and preferences, forbid it for money, orders, inventory and audited records, require a bounded queue, coalescing, versioned writes, lag monitoring and an agreed loss window, and keep database-first with invalidation as the default.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would not make write-behind the default. It moves the system of record into the cache for the length of the delay, trading durability, consistency for other readers and auditability for latency, which suits counters, presence and preferences but not money, orders or inventory. I would allow it by data class, first check whether a tuned database write or a durable log append already meets 10 ms, and where it is allowed require a bounded queue, per-key coalescing, versioned writes, lag monitoring and a loss window the product owner has agreed to.
Why this question is asked
A proposal like this sounds like a pure performance decision, but it is really a decision about where the truth lives. Interviewers ask it at senior level because the right answer is neither yes nor no; it is a policy with conditions and a default that keeps the organisation safe. In this answer, we will recap what write-behind changes, check whether the latency target really needs it, decide which data may use it, set the conditions for using it, and see how to keep the safe path as the default while still allowing the exceptions.
1What Write-Behind Really Changes
There are four common write paths. With cache-aside, the application writes the database and then deletes the cache entry. With write-through, the cache layer writes the database synchronously before acknowledging. With write-around, writes go only to the database and the cache fills on reads. With write-behind, also called write-back, the cache acknowledges the write immediately and updates the database later, asynchronously.
Only the last one changes who holds the truth. Between the acknowledgement and the database update, the cache holds the only copy of the change. If the cache node fails in that window, the write is gone even though the user was told it succeeded. Other services that read the database during the window see the old value. And the audit trail, which usually comes from the database, shows the change late or, after a failure, not at all. So write-behind buys latency with durability, consistency for other readers and auditability. That is a fine trade for some data and a bad one for most business records.
| Path | Acknowledged after | Risk |
|---|---|---|
| Cache-aside | Database commit, then cache delete | Brief stale reads |
| Write-through | Cache and database both written | Write latency of both |
| Write-around | Database commit only | First read after a write misses |
| Write-behind | Cache write only | Loss and stale readers during delay |
2Does the 10 ms Target Need It at All?
Before granting any exception, I would ask each team where its write time goes today. A single-row insert into PostgreSQL in the same zone as the primary usually commits in one to three milliseconds, and even with a synchronous standby it often stays under five. When teams see 40 ms writes, the cause is usually something else: several round trips through an ORM, a missing index on a foreign key, a lock held by a long transaction, or the database in another region. Fixing those keeps durability and reaches the target.
If the work behind a write is genuinely slow, for example it updates several projections, there is a better pattern than write-behind: append the command to a durable log such as Kafka with acks=all, acknowledge once the log has it, and build the other views from the log. An append to a replicated log takes a few milliseconds, and unlike a cache it does not lose the write when one node fails. The latency goal is met without moving the truth into memory.
3Deciding by Data Class
So the rule I would write is about the data, not the team. Write-behind is allowed for data where losing a few seconds of changes is acceptable and nobody reconciles it against money or law: view and like counters, metrics, online presence, last-seen times, UI preferences, recently viewed lists. It is forbidden for payments and balances, orders, inventory and reservations, anything users must be able to rely on after an acknowledgement, and anything with legal, audit or regulatory requirements.
The test I would give teams is a single question: if the last ten seconds of these writes disappeared, would anyone need to be told? If the answer is yes, write-behind is not allowed. The decision flow below is what goes into the caching standard.
- Money, orders, stock or audit data?Legal or financial meaningYesForbidden: database firstNoNext question
- Can a tuned write meet the target?Measure before decidingYesUse the normal pathNoNext question
- Is a durable log append enough?Kafka with acks=allYesUse the logNoNext question
- Product owner accepts a loss window?Written down, in secondsYesAllowed with conditionsNoNot allowed
4 steps in order. Play them, or step through them one at a time.
4The Conditions Where It Is Allowed
Where write-behind is allowed, I would require five things in the design review. First, a bounded queue of pending writes, so a slow database causes backpressure or a deliberate drop policy instead of unbounded memory growth. Second, per-key coalescing, so ten updates to the same key become one database write; that is most of the benefit and it also bounds the queue. Third, versioned writes: each pending write carries a version or timestamp and the database update only applies if it is newer, so a delayed or retried write never overwrites a newer value.
Fourth, monitoring of the lag between acknowledgement and database update, with an alert well inside the agreed window. Fifth, the loss window itself, written in seconds and in business terms, agreed with the product owner, and backed by replicas and persistence settings that actually achieve it. A team that cannot fill in those five items is not ready to use write-behind, whatever its latency target is.
5Keeping the Safe Path as the Default
The most important decision is which path needs justification. If write-behind is the default, every team must argue for durability, and most will not notice they needed it until the first lost order. If the default is database first and then cache invalidation, teams argue only for the exception, and the argument is cheap where the data class clearly allows it.
To make that real, I would provide the safe path in the shared platform library, so it is also the easiest one to use, publish the data-class rules in the caching standard, and keep a short exception record for each write-behind use with its loss window and owner. I would also thank the architect: the proposal surfaced a real latency problem, and the follow-up work on slow writes is part of the answer.
6Follow-up questions
How would you explain the loss window to a product owner?
In their terms and with numbers. I would say: if one cache server fails at peak, the last five seconds of likes may disappear, which is about 20,000 likes out of 30 million a day, and users would see the count drop slightly. Then I would ask whether that is acceptable and what it would cost us if not. Product owners decide well when the loss is concrete, and their written answer becomes the loss window in the design.
What if a team already uses write-behind for orders?
I would treat it as a risk to remove, not a policy violation to punish. First measure the actual exposure: how many orders sit in the cache at once and what failover would lose. Then plan the migration to database-first with the outbox pattern if they need asynchronous side effects, and add monitoring until it is done.
Is write-behind ever needed for very high write rates?
Yes, when the rate is too high for any database to take each event, such as counters or telemetry. Even then the data is usually aggregated, so losing a few seconds changes a number slightly rather than losing a business fact. That is exactly the data class the policy allows.
7Conclusion
In this answer, we saw that write-behind makes the cache the only holder of the truth during the delay, trading durability, consistency and auditability for latency. We would first check whether a tuned database write or a durable log append meets the 10 ms target, allow write-behind only for data like counters, presence and preferences, forbid it for money, orders, inventory and audited records, require a bounded queue, coalescing, versioned writes, lag monitoring and an agreed loss window, and keep database-first with invalidation as the default.
Open with
I would not make write-behind the default, because it changes the system of record: between the acknowledgement and the database write, the cache holds the only copy, so a node failure loses acknowledged writes, other readers see old data and the audit trail is late.
Then, if they want more
That is fine for some data and wrong for most business records. First I would check whether we need it at all. A single-row write near the primary usually takes a few milliseconds, so slow writes usually mean ORM round trips, locks or a remote database, and those can be fixed.
If the work after a write is heavy, appending to Kafka with acks=all and projecting from it gives low latency without losing writes. Where write-behind is still wanted, I would allow it by data class: counters, metrics, presence and preferences yes; money, orders, inventory and anything with audit requirements no.
Allowed uses must have a bounded queue, per-key coalescing, versioned writes so a late write cannot overwrite a newer one, lag monitoring and a loss window in seconds that the product owner signed off. The default stays database first, then invalidate, so teams justify the exception rather than justify durability.
About this answer
- Last updated
- 13 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 official documentation for the version you use. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
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 "As the senior technical leader, how do you decide where write-behind may be used, and...": https://scrivio-interview-library.netlify.app/architecture/caching-strategies/44b6a8400f/