Skip to content

Feeds under skew and changing eligibility

10 min reading

A revision for high-fan-out authors, deletions and access changes

Page details

System Design · Compose complete systems

10 min reading · 25 min with practice

Sources

Published · Last edited:

Prerequisite: Feeds: choose fan-out and stable pagination. For basics, use the independent System Design foundations.

More
20px

Hypothetical scenario. A large Northwind supplier doubles its audience while projection workers recover a backlog. An activity is withdrawn during replay. Dev adds workers and lengthens page caching; Priya asks whether either change prevents the old activity from returning.

Maya: “Can a quick page still violate the withdrawal rule?”

Dev: “We need to follow eligibility and ownership through the replay, not only drain the queue.”

Evolve the existing hybrid feed under concentrated publication and changing eligibility. Charge the actual recipient work, keep source activity authoritative and bound the merge performed for a page. The changed publisher cohort is explicit rather than hidden inside a new average.

Which publisher creates most of the recipient work?

Fan-out-on-write scales with recipients, not just source posts. A single supplier can dominate projection work while ordinary suppliers remain inexpensive. Treating every queued activity equally by message count hides that difference. Charge work in recipient appends or another explicit cost unit before deciding which queue is healthy.

Northwind proposes isolating high-fan-out work from ordinary projection updates. A selected supplier can instead remain in a bounded read-time merge path. That moves work to serving; it does not eliminate it. The choice must include how often followers read, how many supplier histories a page consults and what happens during supplier-class migration.

Recalculate the concentration and recovery margin

Hypothetical worked example. Retain the baseline ordinary group’s two million projection appends per day. Choose a large supplier with one million followers and five daily posts. Its work is 1,000,000 × 5 = 5,000,000 references per day. Combined work is 2,000,000 + 5,000,000 = 7,000,000 references per day before retries.

Now double only that supplier’s followers to two million. Its work becomes 2,000,000 × 5 = 10,000,000 references per day. The ordinary group remains unchanged, so the combined count is 2,000,000 + 10,000,000 = 12,000,000. It would be incorrect to double the entire previous workload merely because one audience doubled.

For a separate recovery interval, select a backlog of one hundred twenty thousand references, successful capacity of twenty thousand appends per minute and ten thousand new references per minute. Net drain is 20,000 − 10,000 = 10,000 per minute, giving 120,000 ÷ 10,000 = 12 minutes. Inconclusive or repeated attempts are not additional successful appends.

If retries consume slots, revise useful capacity before using that result. If new work rises to match the successful completion rate, the backlog no longer drains under the fixed-rate model. Adding storage for a longer queue cannot create recovery margin. The freshness promise needs a declared fallback or a revised resource policy.

Migrate a publisher without losing its overlap

Hypothetical scenario. Publisher P moves from pushed inbox references to pull-on-read. Record a migration generation and source watermark H. Readers merge existing pushed references through H with source posts above the chosen boundary, deduplicating by post identity. The handoff must cover posts accepted while the cohort flag changes.

Migrate a publisher without losing its overlap — selected design evidence
Migration evidenceExamplePurpose
Cohort generationP / generation 8Interpret reader plan
Source watermarkHBound pushed coverage
Dedupe identitypost IDCollapse overlap
Removal statesource version / tombstonePrevent resurrection
Overlap is a deliberate migration phase with deduplication and a named completeness boundary.Overlap is a deliberate migration phase with deduplication and a named completeness boundary. Push cohort to Overlap at H: record boundary + mixed readers; Overlap at H to Pull cohort: prove coverage and removals.Push cohortOverlap at HPull cohortrecord boundary + mixed readersprove coverage and removals
Overlap is a deliberate migration phase with deduplication and a named completeness boundary. Enlarge the diagram to inspect its labels; the surrounding records and explanation give the text alternative.

A flag change alone cannot prove coverage: some old fan-out jobs may still be running and some readers may still use the former plan. Keep versioned cohort metadata and enough overlap for mixed readers. Anti-entropy can compare expected source identities with materialized references and repair omissions under the same permission rules.

Deletion and eligibility changes cross both paths. A deleted post retained in an old inbox must not reappear when the reader merges it with a new pull result. Treat removal evidence and current-source checks as part of migration acceptance, not a later cleanup detail. Rollback must account for posts published after H; simply restoring the old flag can omit them.

Move publishers without losing or duplicating coverage

Changing a supplier from eager fan-out to read-time assembly introduces a transition between two representations. Define a source version or position separating their coverage. A reader may encounter overlapping references during the transition, so merge by stable source identity. Avoid a gap where neither representation contains accepted activity.

The classification itself is derived operational state. A worker using an older classification can continue appending after serving has switched paths. That may be harmless if duplicate recognition and coverage rules allow it, but it must not override a newer withdrawal. Treat the migration as a versioned state transition rather than a boolean flag without history.

A hybrid feed preserves one eligibility boundaryOrdinary publisher references arrive from bounded inbox projections. Large publisher activity arrives through bounded history reads. One merge removes duplicate source identities and applies current visibility before returning the page. Withdrawal evidence also constrains replay into the projections.Ordinary inboxesVersioned projectionLarge-author logsBounded candidatesMerge + identityCursor coverageEligibilityThen page
Different materialization paths share the same reader contract.

Filter before treating a candidate as a result

An inbox reference says that activity was projected, not that the reader may receive it now. Withdrawal, tenant boundaries and follow policy can change after projection. Apply the authority required by the serving contract before rendering. A cache key that contains a reader identifier still needs a valid permission and source-version policy.

Heavy filtering can produce short pages. Fetching more candidates requires a bounded policy so an unusually sparse feed does not turn one read into an unbounded scan. Return the permitted partial result or explicit continuation state when the budget is spent. Do not silently weaken visibility to meet a fixed item count.

Keep page continuity under change

New activity ahead of an offset can shift earlier results into later pages. A cursor representing a deterministic order and tie-breaker can avoid that particular shift, provided the query and source boundaries remain coherent. It still needs rules for removed activity and follow changes.

Introducing personalized ranking would require a new contract for score changes, candidate evidence and session continuity. The present evolution keeps chronological order. Do not use a ranking cache as an unexplained replacement for the established cursor merely because it returns attractive pages quickly.

Replay recreates a removed activity

Hypothetical failure scenario. Activity revision 8 is withdrawn. A rebuilding inbox worker later replays its older revision 7 publication. A cached page now contains the reference again. Deleting the authoritative body alone does not explain whether the page will disclose old content or return a broken entry.

Retain version or tombstone evidence that makes the obsolete publication ineligible. Apply the serving visibility rule while cleanup propagates. A rebuild needs the removals and policy transitions relevant to its source boundary, not only creation events. Otherwise recovery restores a representation the product explicitly rejected.

In the wild: a timeline API names its read boundary

Mastodon’s timeline documentation specifies read parameters and authentication requirements. It is useful evidence that pagination and eligible access are public contracts. It does not imply a particular fan-out implementation, so Northwind’s mixed materialization remains an explicit design proposal.

Spend complexity where the skew requires it

Use a mixed path when publisher concentration and follower-read demand justify it. Preserve ordinary publication progress with isolated budgets, and bound serving fan-in for large publishers. Do not introduce an independent platform for every hot supplier unless ownership and resource evidence support that additional operational boundary.

Measure projection age, useful appends, candidate-to-return ratio, permission rejections and page continuity. Compare those with the declared freshness and latency goals. A fast source-post insert can coexist with a stale reader feed. A full page can coexist with unauthorized disclosure. Measure the outcome being promised.

Challenge the proposed mechanism

A stale pushed reference cannot override a newer source removal during the handoff.A stale pushed reference cannot override a newer source removal during the handoff. Source removal to Reader merge: 1 · post withdrawn; Old push worker to Reader merge: 2 · late reference; Reader merge to Source removal: 3 · verify / suppress.Old push workerReader mergeSource removal1 · post withdrawn2 · late reference3 · verify / suppress
A stale pushed reference cannot override a newer source removal during the handoff. Enlarge the diagram to inspect its labels; the surrounding records and explanation give the text alternative.

A post is deleted during the cohort switch, then an old fan-out job appends its reference. What rejects display?

Reveal the design reasoning

Current source eligibility or version-bound removal evidence must override that stale reference. The materializer should also reject obsolete state where possible. Test the late job, mixed reader and rollback together.

Decision and reconsideration: Change feed cohorts through watermarks and overlap, retaining source authority on every display path.

Defend the evolved feed

  1. One large supplier doubles its followers. Does all fan-out double?

    Revise only the changed cohort

    No. Its selected five million appends become ten million, while the ordinary group remains two million. The combined count changes from seven million to twelve million.

  2. A rebuild has old publication events but no withdrawal evidence. Is it ready?

    Preserve semantic recovery

    No. Replaying creation alone can resurrect removed activity. Obtain the necessary versions and removals or keep the reconstructed view ineligible until its state can be justified.

  3. Filtering leaves fewer than the desired page size. Should visibility be relaxed?

    Bound work without weakening permission

    No. Fetch more only within the declared budget, then return a permitted partial or continuation result. Page fullness does not override eligibility.

Feed recovery relies on evidence about derived state. Page 47 begins a money-movement case where the authoritative journal, external provider and spending decision need separately defined responsibilities.

Northwind decision log

Isolate concentrated fan-out while preserving one merge and coverage contract.
Keep withdrawal evidence effective during replay and serving.
Next, define payment-ledger authority before external execution.

Go deeper: communication failure and resilience