Scrivio Interview library
LeadershipPrincipal6 min read · updated 13 November 2026

Customer account balances in your company are computed by Kafka Streams applications with exactly_once_v2 and shown in a banking app. Internal audit asks you to prove that balances are correct and will stay correct as code and platform change.

How do you answer, and which controls and investments do you put in place?

I would tell audit that exactly_once_v2 is a mechanism, not a proof: it stops Kafka-internal duplicates on failure, but it cannot catch code bugs, bad input, misconfigured consumers or manual offset resets. Proof comes from independent controls: a daily reconciliation that recomputes balances from the immutable ledger, invariants checked inside the pipeline with a quarantine path, controlled change with replay and chaos tests, and an explicit decision about which store is the system of record.

Why this question is asked

When money is involved, an auditor's question is not whether the technology is clever but whether we can show, with evidence, that the numbers are right and will stay right. Engineers who answer with a description of Kafka transactions miss the point, and interviewers ask this question at leadership level to see whether we can separate a delivery guarantee from business correctness and turn that difference into controls, owners and budget. In this answer, we will separate mechanism from proof, design an independent reconciliation, put invariants into the pipeline, control change to code and platform, and decide where the authoritative ledger lives.

1Separating the Mechanism From the Proof

Exactly-once in Kafka Streams guarantees that, for each input record, the state change, the output records and the consumed offset are committed together once, even when instances crash. That is valuable: it removes a whole class of duplicate and lost updates caused by failures. But it is a statement about how processing survives failure, not about whether the processing is right.

So my first answer to audit is honest about the boundary. A balance can still be wrong for reasons exactly-once does not touch, and our controls must catch those. Listing them makes the gap concrete and gives each control a reason to exist.

What exactly-once does and does not protect
RiskCovered by exactly_once_v2?Control that covers it
Instance crash mid-batchYesTransactions
Bug in the balance logicNoReconciliation, invariants, replay tests
Malformed or duplicate input from upstreamNoInvariants, quarantine topic
Consumer reading with read_uncommittedNoConfig checks, reconciliation
Manual offset reset or transaction abortNoApprovals, audit log
Lost local state during an upgradePartly (changelog)Rebuild drills, reconciliation

2An Independent Reconciliation

The strongest evidence an auditor can get is a second, independent computation that agrees with the first. We build a reconciliation job that recomputes every account's balance from the immutable source, either the transaction topic with long or infinite retention, or the ledger of record in a database, using separately written code. It runs daily, compares per-account balances and overall totals with what the Streams app shows, and stores the result.

Independence matters. If the reconciliation shares the same library as the stream app, a bug in that library makes both agree on a wrong number. So it is written by a different team or at least a different code path, ideally as a plain batch query. Any difference raises an alert, opens an incident with a named owner, and follows a documented correction process: find the cause, correct through compensating transactions rather than editing state, and record the outcome. The history of daily results, mostly zero differences with each exception explained, is the evidence audit wants.

3Invariants Inside the Pipeline

Reconciliation finds errors after a day. Invariants find many of them at once. These are rules that must always hold, checked as records flow, with violations routed to a quarantine topic and a page to the on-call engineer instead of being silently applied.

Java
public void process(Record<String, Transfer> r) {
Transfer t = r.value();
long sum = t.entries().stream().mapToLong(Entry::amountCents).sum();
if (sum != 0) { quarantine(r, "debits and credits do not net to zero"); return; } // -500 + 400 = -100
Long last = seqStore.get(t.accountId());
if (last != null && t.sequence() <= last) { quarantine(r, "sequence not increasing"); return; }
long newBalance = balanceOf(t.accountId()) + amountFor(t.accountId(), t);
if (newBalance < -overdraftLimit(t.accountId())) { quarantine(r, "balance below allowed limit"); return; }
apply(t, newBalance); // only now update stores and forward
}

The point is not this exact code but the habit: every rule the business states about balances becomes a check with a counter and an alert. Quarantined records are visible, counted and resolved by people, which is itself a control audit can sample.

4Controlling Change to Code and Platform

Audit also asked whether balances will stay correct as things change, and most incidents in mature stream systems come from change, not from crashes. We name and version every topology, because Kafka Streams derives internal topic and store names from the topology and an unplanned change can orphan state. State migrations are planned steps with a rollback.

Before each release we replay a production-like slice of transactions through the new version and diff its balances against the current one. We run chaos tests regularly: kill instances and brokers under load, then reconcile and show zero differences. Manual actions that bypass the normal path, such as resetting offsets, aborting transactions or editing topic configs, require an approval and leave an audit log entry. And we verify consumer settings, such as read_committed on every reader of balance topics, with automated checks rather than trust.

Step throughRelease path for a balance topology
  1. Code review and versioned topologynames of stores and topics fixed
  2. Replay production-like datadiff balances against current version
  3. Differences explained?
    Yeschaos test under loadNofix before release
  4. Kill instances and brokersthen reconcile: expect zero differences
  5. Approved releasewith rollback plan for state

5 steps in order. Play them, or step through them one at a time.

5Deciding Where the System of Record Lives

The last question is the one many teams leave implicit. Is the Streams state the authoritative ledger, or a fast derived view of one? Many banks keep the ledger of record in a relational database with constraints and serializable transactions, and use streaming to compute balances for the app. Others treat an immutable transaction topic as the ledger and everything else as derived. Both can work, but the choice must be explicit and documented, because it decides what reconciliation compares against and which data must be retained forever.

Whichever we choose, we measure how long a full rebuild of state takes from the source, for example six hours for 40 million accounts, and test it. That number is part of the answer to audit: if state is ever corrupted, here is how and how fast we recover. The investments I would ask for are the reconciliation job and its team, the replay and chaos environment, and the time to write and maintain invariants.

6Follow-up questions

What evidence would you show from your last failure test?

I would show the test plan (which instances and brokers we killed, at what load and for how long), the reconciliation result afterwards with zero per-account differences across all accounts, the duplicate and quarantine counters during the test, the recovery time we measured against our target, and any issues found with the tickets that fixed them. A test with a finding that was fixed is better evidence than a test that claims nothing happened.

Is exactly-once still worth having if we reconcile daily anyway?

Yes. Reconciliation detects and bounds errors; exactly-once prevents a common class of them from happening at all. Without it, every crash would create differences to investigate, and the reconciliation process would drown in noise.

Who should own reconciliation?

Ideally a team separate from the one that owns the streaming app, or at least a separate code path with its own reviewers, so that one mistake cannot make both computations agree on a wrong answer.

7Conclusion

In this answer, we separated the exactly-once mechanism, which protects Kafka-internal processing from failure duplicates, from the proof audit wants. We added an independent daily reconciliation against the immutable ledger, invariants with a quarantine topic, controlled change through versioned topologies, replay and chaos tests and approvals for manual actions, and an explicit decision about where the system of record lives and how long a rebuild takes.

What to say in the interviewAbout 80 seconds aloud

Open with

I would start by separating mechanism from proof. Exactly-once in Kafka Streams makes sure that when an instance fails, a transfer is not applied twice or lost inside Kafka.

Then, if they want more

It does not prove that our business logic is right, and it does nothing about code bugs, bad input, a consumer reading with read_uncommitted, or someone resetting offsets by hand. So the proof has to come from independent controls.

First, a reconciliation job written separately that recomputes balances from the immutable transaction topic or the ledger of record every day, compares per account and in total, alerts on any difference and follows a documented correction process.

Second, invariants in the pipeline: each transfer's debits and credits net to zero, balances respect account rules, per-account sequence numbers increase, and violations go to a quarantine topic and page someone.

Third, change control: versioned topologies and planned state migrations, replay tests on production-like data before every release, chaos tests that kill instances and brokers under load followed by reconciliation, and approvals with an audit trail for manual actions on offsets or transactions.

Finally, I would make explicit where the system of record lives, often a database ledger with streams as derived views, and measure how long a full rebuild takes.

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 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
Apache Kafka 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 "How do you answer, and which controls and investments do you put in place?": https://scrivio-interview-library.netlify.app/spring-boot/kafka-streams-connect/673dbbd612/