skip to content

A team wants one shared stream writable at both sites — why do operators propose one stream per site instead, and what does that cost readers?

level: principalimportance: should knowfreq 38%

answer

  1. two writers is the whole problem
  2. one owning writer per stream
  3. written at one site, read everywhere
  4. the combining moves into the reader
  5. hops grow with the square

basics

~20 s

One stream written at two sites has no defined order across them and needs loop prevention on every hop just to exist. Giving each site its own stream with one owning writer, read everywhere, removes both problems and moves the combining work onto readers.

solid answer

~50 s

Every hazard in this arrangement descends from one object having two writers: the echo between facing copiers, the two orderings nothing can merge, and readers at the two sites seeing different interleavings. A **per-site stream** — written only at the site that owns it, read everywhere — removes the cause rather than managing it: no stream ever has a second writer, so no hop needs an origin stamp and each stream carries its own writer's order. The cost is real and lands on the reader side. A consumer that read one name now reads one per site, gains another when a site is added, and owns the combination rule explicitly. That is the trade worth defending: the merging work does not vanish, it moves from somewhere nobody can justify it to somewhere someone had to write it down.

go deeper

for a junior

Recall the shape: a per-site stream is written only at the site that owns it and read at every site. That single owning writer is what makes the arrangement simple, and readers consume one such stream per site.

for a middle

Explain the two things a single owning writer buys: no hop needs loop prevention, and each stream carries one writer's order. Then state the cost, which is that readers subscribe per site and combine the streams themselves.

for a senior

Show that you would price the reader-side fan-in, the stream count and the hop count before agreeing to either shape, and that you know cross-site aggregates now depend on holding every stream and on the slowest hop.

for a principal

Argue the posture: which request is really on the table, whether n(n−1) hops are sustainable as the estate grows, whether anyone will rehearse the failure, and whether the stamping discipline will still be honoured by the operator who adds the next hop.

## What the request actually asks for 'One shared stream, writable at both sites' asks for a single named object with **two independent writers** and one agreed content. Everything that goes wrong in this arrangement descends from those two writers: - Two copiers facing each other echo a record back and forth without bound unless every hop carries an origin stamp and honours it. - Two sites sequencing the same stream produce two orderings, and no after-the-fact merge recovers a true order across them, because none was ever recorded. - Readers at the two sites see different interleavings of the same records, so state folded from the stream differs by site. ## What one stream per site changes A **per-site stream** is written only at the site that owns it and read everywhere. Each site keeps producing, and each site still ends up holding all the records. The difference is that no stream ever has more than one writer. | Property | One shared stream, written at both sites | One stream per site | |---|---|---| | Loop prevention | mandatory: every hop must stamp and filter | unnecessary: nothing copies into a stream another site writes | | Ordering | undefined across the two sites | each stream carries its single writer's order | | Duplicates | the echo, plus copier restarts | copier restarts only | | Reader work | one subscription, one apparent sequence | one subscription per site, combined explicitly | | Adding a site | another pair of stamped hops and a new source of unordered writes | one more stream, read wherever the others are | | Where combining happens | inside the stream, implicitly, on no defensible rule | inside the reader, visibly, on a rule someone chose | The last row is the whole argument. The merging work does not disappear; it moves from a place where nobody can see or justify it to a place where a person had to write it down. ## The cost, stated honestly - **Fan-in moves to the reader.** A consumer that read one name now reads several, and adding a site changes what every consumer reads. Where the reader is one process treating the streams as a set, that is trivial; where it maintains per-entity state, the combination rule is now its explicit problem. - **Cross-site aggregates get harder before they get better.** Any 'total across all sites' answer now depends on the reader holding every stream and on the slowest hop feeding it. - **The stream count multiplies.** One logical subject becomes one stream per site, which matters wherever a platform charges per stream, caps how many exist, or spends fixed overhead on each. - **Hops grow with the square of the sites.** If every site must hold every other's streams, an estate of *n* sites wants n(n−1) directed hops. That, not ordering, is usually what caps the shape in practice; beyond two or three sites, estates route through a hub or abandon the idea that every site holds everything. ## When a shared writable stream is still defensible It is defensible where nothing downstream depends on order across sites and duplicates are harmless — an append-only measurement or audit feed folded into counts, or a stream whose single consumer treats it as a set. Even then, the stamping discipline on every hop becomes a standing obligation someone must maintain forever, including on the hop added at two in the morning during an incident by whoever is on call. ## What a lead is really being asked to decide Most requests for writes at both sites are one of two other requests wearing a costume: 1. **'Writers must keep working when their nearest site is unreachable.'** That is a routing question — where a writer goes when its site is gone — and it is answered by the switch onto a standby, not by dual acceptance. 2. **'Readers want the data locally.'** That is answered by copying a single-writer stream outward, which is exactly the per-site arrangement. Separating those two usually ends the argument, and naming which one was actually asked for is the move expected at this level. The remaining honest questions are whether the organisation will ever rehearse the failure the design exists for, and whether it will keep the discipline the design needs on every hop anyone adds later. ## Where platforms differ - On a queue-shaped broker, one queue per site drained by competing consumers is close to the natural shape already, so the per-site arrangement costs little conceptually. - On a platform that splits a stream into parts, per-site streams multiply the parallelism accounting: each stream carries its own part count, and the reader side has to be sized against the sum rather than one number. - On a rented cluster the ceiling may not be yours to raise. Stream counts, hop counts and cross-site bandwidth can each be capped by the offering, which changes the arithmetic before any design argument begins.

  • What usually drove the request for a stream writable at both sites?
    Almost always one of two things that do not need it: writers that must keep working when their nearest site is unreachable, or readers that want the data locally. The first is a routing question answered by the switch onto a standby; the second is answered by copying a single-writer stream outward. Naming which one was asked for normally ends the design argument.
  • How many copy hops does an estate of four sites need if every site must hold everything?
    With per-site streams, one hop per ordered pair — twelve directed hops for four sites, each carrying only its source's own streams. The count grows with the square of the site count, which becomes the practical ceiling long before ordering does. Most estates stop at two or three sites, or route through a hub so each site maintains one relationship instead of several.
  • Does one stream per site remove duplicates entirely?
    No. It removes the echo, because no stream ever has two writers, but a copier resuming from an earlier point still re-appends records it had already carried, and readers absorb those. What changes is that duplicates now have one bounded cause an operator can reason about, instead of an unbounded loop that grows at both sites.

saying these in an interview costs you the question

  • Calls one stream per site a workaround rather than the design
  • Assumes two-way copying leaves both sites holding one merged sequence
  • Thinks adding a third site is just one more copy hop
  • Promises writes at both sites without saying who owns each entity
  • Claims readers need no change when one site becomes two
  • Treats the reader-side fan-in as free because subscriptions are cheap