Scrivio Interview library
DesignAdvanced7 min read · updated 12 November 2026

Define a consistency standard for your platform so that teams describe and choose consistency deliberately instead of by database default. What levels would you name and how would you enforce them?

I would name a small set of levels: linearizable; transactional, meaning serializable or snapshot isolation; session, meaning read-your-writes and monotonic reads; and eventual with a stated staleness bound. Every design review must state the level per operation and its behaviour during failures. The platform maps each level to concrete settings per database, such as isolation levels, quorum levels and replica routing, ships tested library support such as session-consistent replica routing, and verifies critical systems with Jepsen-style fault injection, so consistency becomes a deliberate, checked choice rather than whatever the database default happens to be.

Why this question is asked

Ask five teams what consistency their service provides and you will get five vague answers: 'it uses PostgreSQL', 'Cassandra at QUORUM', 'it is eventually consistent, I think'. Each answer describes a product setting, not a promise to the callers, and many are just defaults nobody chose. Bugs follow: a stale balance, a lost update, a user who cannot see their own change. Interviewers ask this design question to see whether we can create a shared vocabulary and make it enforceable across an organisation. In this answer, we will see why defaults are a problem, define the levels, make every design state them per operation, map them to database settings, provide library support, and verify the important ones.

1Why Database Defaults Are Not a Decision

Defaults differ widely. PostgreSQL defaults to READ COMMITTED, which allows lost updates in read-modify-write code. MySQL's InnoDB defaults to REPEATABLE READ. Cassandra drivers default to a consistency level of LOCAL_ONE in recent versions, which can read stale data. MongoDB's default read concern returns data that may later be rolled back after a failover in some configurations. A team that never touched these settings has made a choice without knowing it.

The deeper problem is that the callers of a service do not see the database at all. They see an API, and they need to know what it promises: will I see my own write, can two requests both succeed, how stale can this be? A consistency standard gives everyone the same words for those promises.

2Naming a Small Set of Levels

The set must be small enough that every engineer can remember it and precise enough to mean something. Four levels cover nearly all needs. Linearizable: the operation behaves as if there were one copy, and once a write completes every later read sees it; used for unique usernames, leader election, stock reservations. Transactional: multi-step operations run as if alone, serializable where invariants span rows, snapshot isolation where read-only consistency is enough; used for payments and ledgers. Session: within one user's session, reads see that user's own writes and never go back in time (read-your-writes and monotonic reads); used for profiles and settings. Eventual with a staleness bound: reads may be stale, but by no more than a stated time, such as 30 seconds; used for catalogs, feeds and counts.

The staleness bound is the important addition to 'eventual'. Without a number, eventual consistency can mean a second or a day, and nobody can design or test against it.

The platform's consistency levels
LevelPromiseTypical use
LinearizableActs like one copy; latest write always visibleUnique names, stock, locks
TransactionalMulti-step operations isolated (serializable or snapshot)Payments, ledgers
SessionRead-your-writes and monotonic reads per userProfiles, settings, carts
Eventual, bound TStale by at most T, e.g. 30 sCatalog, feeds, counters
Stronger levels cost latency and availability, so each must be justified.

3Stating the Level per Operation in Design Reviews

The standard becomes real in the design template. For every data store a service uses, the design lists its main operations and states, for each, the level and its failure behaviour. A service is rarely one level: in an order service, 'reserve stock' may be linearizable, 'place order' transactional, 'view my orders' session and 'order count badge' eventual with a 60 second bound. Failure behaviour says what happens when the level cannot be met, for example 'if the quorum is unavailable, reserve stock returns 503 and the client retries', or 'during replica lag above 5 seconds, my orders reads from the primary'.

Reviewers check two things: that the chosen level fits the business risk, and that the settings described actually provide it.

4Mapping Levels to Database Settings

Engineers should not have to rediscover how to get each level from each database. The platform team publishes one mapping per supported store, reviewed and tested.

Text
Level PostgreSQL Cassandra (RF 3) MongoDB
------------- ----------------------------- -------------------------- ---------------------------------
Linearizable primary, row lock or SERIALIZABLE lightweight transaction (IF) readConcern linearizable,
writeConcern majority
Transactional SERIALIZABLE or REPEATABLE READ not supported: redesign multi-document transaction,
on the primary snapshot read concern
Session primary, or replica after LSN LOCAL_QUORUM reads + writes causally consistent session,
check (library) majority read and write concern
Eventual, T any replica, lag alert at T LOCAL_ONE, repair schedule secondary reads, lag alert at T

Notice that some cells say 'not supported'. Cassandra offers no multi-row transactions across partitions in the versions most teams run, so an operation that needs that level must be redesigned or moved. Writing that down stops teams from assuming a guarantee their database cannot give. The exact settings and their names change between versions, so the mapping is owned and kept current by the platform team, and every cell has a test.

5Providing Tested Library Support

A standard that requires every team to write tricky code will be implemented badly in places. So the platform provides libraries for the levels that need application logic. The most common is session-consistent replica routing: a Spring component that records the primary's log position after a write in the user's session and routes reads to a replica only once it has replayed that position, falling back to the primary otherwise. Teams declare the level they want, and the library does the rest.

Java
@ConsistencyLevel(Level.SESSION) // provided by the platform library
@Transactional(readOnly = true)
public Profile profile(long userId) {
return profiles.findById(userId).orElseThrow();
// library: replica if it has replayed this session's last write LSN, else primary
}
@ConsistencyLevel(value = Level.EVENTUAL, maxStalenessSeconds = 60)
public long unreadCount(long userId) { ... } // any replica; metric fails if lag > 60 s
Step throughHow the standard is enforced
  1. Design reviewlevel and failure behaviour per operation
  2. Code annotation@ConsistencyLevel on each operation
  3. Platform libraryrouting, quorum and isolation settings
  4. Database settingsfrom the published mapping
  5. Verificationmetrics, fault injection, Jepsen-style tests

5 layers, from the top down. Step through them one at a time.

Notice that the annotation also documents the promise in the code, where reviewers and new engineers can see it. The library emits metrics per level, such as how often session reads fell back to the primary and the observed staleness of eventual reads, which tells us whether the promises hold in production.

6Verifying With Fault Injection

Claims about consistency are only tested by failures, and failures are rare, so we cause them on purpose. For critical systems, such as payments, stock and identity, we run Jepsen-style tests: many clients perform operations concurrently while a tool injects network partitions, node crashes, clock skew and pauses, and a checker analyses the recorded history to find any result that violates the claimed level, such as a read that went back in time or two successful reservations of the same unit. The open source Jepsen library and its Elle checker are the reference for this kind of testing.

For less critical systems, lighter checks are enough: integration tests that stop a replica or delay replication and assert the documented failure behaviour, and game days that exercise a regional failure. Findings feed back into the mapping, which gets better with every test.

7Follow-up questions

Why not just require the strongest level everywhere to be safe?

Because stronger levels cost latency, throughput and availability. Linearizable reads across regions add a round trip to every request and fail during partitions. Applying them to a product catalog would make it slower and less available for no business gain. The standard asks teams to choose the weakest level that is still correct for each operation.

How do you handle legacy services that never stated a level?

We do not demand a big audit. Each service states its levels the next time it goes through design review or a significant change, and critical services are reviewed first.

What is the difference between session and causal consistency?

Session guarantees cover one client: its own writes and the order of its reads. Causal consistency extends this across clients: if a user sees a comment and replies, everyone who sees the reply also sees the comment it answered. It is stronger than session and weaker than linearizable, and some databases, such as MongoDB with causally consistent sessions, support it within a session.

8Conclusion

In this answer, we saw how to replace database defaults with deliberate consistency choices. We named four levels, linearizable, transactional, session and eventual with a staleness bound, required each design to state the level and failure behaviour per operation, mapped every level to concrete settings for each supported database, provided platform libraries such as session-consistent replica routing with annotations and metrics, and verified critical systems with Jepsen-style fault injection.

What to say in the interviewAbout 80 seconds aloud

Open with

I would define a small vocabulary that every team uses. Linearizable, where operations act as if there is one copy, for things like unique usernames and stock reservations.

Then, if they want more

Transactional, meaning serializable or snapshot isolation for multi-step operations such as payments. Session, meaning read-your-writes and monotonic reads for one user, for profiles and settings. And eventual with an explicit staleness bound, like 30 or 60 seconds, for catalogs and feeds.

Then every design review has to state, for each important operation, which level it needs and what happens when that level cannot be met, for example returning 503 or falling back to the primary.

Since defaults differ so much, PostgreSQL at read committed, Cassandra drivers at LOCAL_ONE, the platform team would publish a mapping from each level to concrete settings per database: isolation levels, quorum levels, lightweight transactions, MongoDB read and write concerns, replica routing, including where a level is not supported.

We would ship tested libraries for the hard parts, such as session-consistent replica routing based on log positions, exposed as an annotation that also documents the promise in code and emits metrics. Finally, critical systems would be verified with Jepsen-style fault injection, and others with lighter tests and game days.

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, MongoDB manual
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 "Define a consistency standard for your platform so that teams describe and choose...": https://scrivio-interview-library.netlify.app/databases/nosql-fundamentals/5de7f94a45/