A stream is configured with both a seven-day age bound and a byte ceiling — which one decides when the oldest record is removed?
answer
- two bounds, not one
- the earlier one wins
- throughput decides which binds
- a byte ceiling needs its scope
- oldest-first, never newest
basics
~20 sWhichever binds first. Both bounds are live at the same time, and the oldest records become removable as soon as either the age is reached or the bytes are reached, so a busy stream hits the byte ceiling long before seven days.
solid answer
~50 sBoth are enforced at once and neither overrides the other: the store removes the oldest records as soon as **either** the age bound or the byte ceiling is reached — whichever binds first. Which one that is depends on throughput, not on configuration. At 30 GB a day a 500 GB ceiling binds at about sixteen days, so the seven-day age bound wins and the ceiling is only a guard on the data volume; triple the traffic and the same ceiling binds at about five and a half days, so the span of history that is actually readable quietly becomes shorter than the number anyone typed. Before you can predict anything you also have to know what scope the byte ceiling counts — each partition of a stream, the whole stream, or a per-subscriber backlog — because platforms differ, and some offer only an age bound at all.
go deeper
Recall that two bounds can be live on the same stream — an age and a number of bytes — and that the first one reached removes the oldest records. Say the words 'whichever binds first'.
Explain the arithmetic: a byte ceiling divided by the current write rate is a span in days, and comparing that span to the age bound tells you which bound is actually doing the work today.
Show that you monitor the readable span itself rather than the configured numbers, and that you know a traffic surge shortens it with no error raised anywhere.
Frame the two bounds as a policy choice: the age bound is the promise you make to readers, the byte ceiling is the guard on capacity, and letting the ceiling bind routinely means the promise is fiction.
## The two bounds A store that keeps records for a while needs a rule for when a record stops existing. Platforms in this class typically offer two, and most production streams have both set: - **An age bound** — the maximum age a record may reach before it becomes removable. *Keep seven days.* - **A byte ceiling (a size bound)** — the maximum bytes a named scope may occupy before the oldest records become removable. *Keep five hundred gigabytes.* They are not alternatives, and neither one overrides the other. A background **removal pass** evaluates both, and the oldest records become removable as soon as **either** is reached. That is the whole rule, and it has a name worth using in an interview: **whichever binds first**. Note the direction: a size bound removes the **oldest** records, not arbitrary ones and not the newest. The span of history that survives is therefore always a suffix — the most recent records — and the front of the history is what moves. ## Which one binds is arithmetic, not configuration Given a write rate, each bound implies a span of readable history: - the age bound implies its own number directly (seven days means seven days); - the byte ceiling implies `ceiling ÷ current byte rate`. At 30 GB/day into a scope whose ceiling is 500 GB, the ceiling implies about 16 days, so the 7-day age bound binds first and the ceiling never fires: it is acting purely as a guard on the data volume. Push the rate to 90 GB/day and the ceiling implies about 5.5 days — now the ceiling binds first and the age bound never fires. Nothing has been misconfigured and nothing has failed. The span that survives is a **consequence of throughput**, not a promise made by the configuration. | | age bound | byte ceiling | |---|---|---| | what it measures | how old a record is | bytes held in one stated scope | | under a traffic surge | the span holds, the bytes grow | the bytes hold, the span shrinks | | what it protects | a predictable span of history | the data volume | | how it disappoints you | bytes can grow beyond plan | history shortens with no error | ## The byte ceiling is meaningless without its scope "Five hundred gigabytes" answers nothing until you know **five hundred gigabytes of what**. Platforms state a size bound against different scopes: - **per partition of a stream** — a stream with twenty-four partitions then holds up to twenty-four times the number you typed; - **per stream as a whole** — the number means what it looks like; - **per subscriber backlog** — the bytes counted are the ones a particular subscriber has not taken yet, so the same stream costs more as subscribers are added; - **nowhere** — some platforms express retention only as an age and leave capacity entirely to you. Always say the scope out loud. An operator who quotes a ceiling without its scope cannot size anything. ## The span that survives is the replay budget The span of history still readable right now is **the retention window**, and it is worth naming it as what it actually buys you: the retention window *is* **the replay budget**. It is how far back anything can be re-read — by a reader recovering after a bad deploy, by a new consumer being brought up on history, by an investigation. Whatever the two bounds produce, that is the budget, and it is spent silently. Nobody is notified when it shrinks; there is simply less history there the next time someone looks. ## What varies between platforms - Platforms that split a stream into partitions usually count a size bound per partition and enforce it as the segments of that partition roll closed. - Platforms built around a per-subscriber backlog count bytes, and sometimes an age, against what each subscriber still owes itself. - Some hosted offerings expose an age bound only, and manage the bytes themselves. - Where a size bound exists at all, oldest-first removal is near-universal; where it does not, age is the only lever you have. Saying *which* model you are describing is not hedging — it is the content. A candidate who describes only the shape they have personally run is the one an interviewer catches. ## What interviewers listen for - The phrase **whichever binds first**, not "the stricter one" and not "one overrides the other". - That the byte ceiling needs a **scope** before it means anything. - That the age bound is a **ceiling on age**, not a guarantee of survival. - That the readable span is a derived quantity you should be watching, not a setting you can read off a configuration page.
- What must you establish about a byte ceiling before you can turn it into a capacity number?The scope it is counted against. The same figure can mean the whole stream, each partition of a stream, or one subscriber's untaken backlog. Per-partition scope multiplies the number by the partition count; per-subscriber scope multiplies it by the number of subscribers. Without the scope, the figure is not a capacity plan.
- If the age bound is seven days, can a record older than seven days still be read?Yes, routinely. Enforcement is coarse: stores that append into rolled segments remove whole closed segments, never single records, and the segment still being appended to is not removed at all. So the surviving history is always somewhat more than the bound, and it shrinks in jumps rather than continuously.
- Does raising the byte ceiling recover history that has already been removed?No. Removal is destructive on this store: raising either bound changes what is kept from now on and returns nothing. Recovering removed history means reading it from somewhere the same bytes still exist, which is a different system's problem, not a retention setting.
A car park with a two-hour parking limit and five hundred spaces. On a quiet day the clock empties it; on a match day the spaces run out first and cars are moved on long before two hours. Neither rule changed — the traffic did.
saying these in an interview costs you the question
- Thinks the age bound alone decides how long history survives
- Says the larger of the two settings wins, or that one overrides the other
- Assumes a byte ceiling counts the whole stream without checking the scope
- Treats the configured age as a promise that records survive exactly that long
- Believes a size bound removes the newest records, or arbitrary ones
- Thinks raising a bound brings removed records back