Estimating Document Read Time in a Collaborative Writing Tool
System DesignModel answerLast updated
Design a read-time estimation feature for a cloud document editor: model, validation strategy, system architecture, and success metrics.
Document Read-Time Estimation
A cloud-based document editor wants to show readers an upfront estimate of how long a document will take to read — something like "~6 min read" in the document header, in share notifications, and in file browser previews.
Your task is to design this feature end to end.
Answer the following four parts:
1. Scoping and users Who benefits from this estimate and in what situations? What constraints matter most at scale (latency, cost, privacy)?
2. Estimation model How would you compute a baseline estimate? What factors beyond raw word count should influence the result? How would you handle non-Latin scripts, code blocks, images, and tables? Describe how you would improve the model once you have real usage data.
3. Validation with real data How would you define "actual reading time" given that raw session duration is noisy? What signals would you collect, and how would you build ground truth? How would you evaluate the model offline and online? What privacy constraints apply?
4. System and architecture Sketch the client, backend, and data pipeline components. Where is the estimate computed, and why? How does it stay fresh as the document changes?
5. Success metrics What metrics would tell you the feature is working? Include guardrails.
A strong answer is structured, makes trade-offs explicit, gives concrete numbers where useful, and anticipates failure modes.
Hints
Hint 1
Raw session duration (time the doc is open) is a terrible proxy for reading time — think about what signals actually tell you a person is actively reading versus leaving a tab open. Define 'completed read' precisely before you pick a metric.
Hint 2
The estimate needs to appear in places where the document isn't open yet (share emails, file browser). That forces a server-side computation path in addition to any client-side logic — think through how you reconcile the two.
Hint 3
Resist the urge to build a complex ML model first. A well-chosen heuristic shipping on day one gives you a baseline to beat, a production signal to learn from, and a fallback if the learned model regresses. Argue for the simplest thing that is useful, then layer in complexity.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
Approach
This is a hybrid product-sense and system-design question. The interviewer is checking whether you clarify before building, whether you think rigorously about ground truth, whether you keep the system proportionate (this is a small feature on a massive product), and whether you name privacy constraints without being prompted.
1. Scoping
Start by anchoring on who actually benefits and why.
Users: Readers deciding whether to open a shared doc now or defer it ("Is this a 3-minute skim or a 40-minute read?"). Authors calibrating length. Reviewers triaging a queue of pending documents.
Surfaces: A label in the document header, share and notification emails, and file-browser card previews. A secondary surface is "~3 min left" based on how far down the document the reader currently is.
Constraints that dominate every decision:
- The platform handles billions of documents and hundreds of millions of daily opens. The estimate must add no perceptible latency to document load.
- Privacy: timing signals touch user behavior data; document content must never leave the client as raw text.
- Accuracy bar: within roughly ±25% is enough to be useful. A "~7 min" label that is actually 9 minutes is fine. A label that says "2 min" for a 20-minute document is not.
State this principle explicitly: round to whole minutes, show "<1 min" below about 30 seconds, and never display false precision like "6 min 43 sec."
2. Estimation model
Baseline heuristic (ships day one, runs on the client)
estimate = body_words / WPM
+ Σ image_cost(i)
+ table_cells × seconds_per_cell
+ code_chars / CPM_code
- WPM: Silent reading of general non-fiction averages around 240 wpm. Use ~200 for dense technical content. This single constant explains most of the variance.
- Non-space-delimited scripts (Chinese, Japanese, Thai): count characters instead of words; ~260 characters per minute is a reasonable starting point. Detect language per paragraph, not per document.
- Images: Apply a decaying cost — 12s for the first, reducing by 1s each subsequent image, floor at 3s. People skim later images.
- Tables: Either count cell text as words at 0.7× the normal rate, or charge a flat cost per cell (~2s).
- Code blocks: Slower reading; use ~40–50 characters per minute and subtract code text from the main word count.
- Exclusions: Strip table-of-contents entries, headers and footers, and deleted suggested-edit text. These inflate the count without adding reading burden.
Learned model (V1)
Once you have real usage data (Section 3), train a regression on log(reading time):
Features: word count, language, readability score (average sentence length, Flesch-Kincaid or equivalent), fraction of text that is code or numeric, heading density (more headings → more skimmable), image and table counts, inferred document type (meeting notes, spec, essay), and opener context (mobile vs desktop, opened from email vs Drive).
Model choice: Gradient-boosted trees or a regularized linear model. The linear model is preferable in practice because its coefficients can be shipped as a tiny JSON config to the client and evaluated in under a millisecond. A tree model can be distilled into a lookup table if needed.
Personalization (V2): Compute a per-user speed multiplier estimated from that user's prior completed-read sessions. Apply Bayesian shrinkage toward 1.0 so new users fall back to the population estimate. Show "~7 min read for you" in the personal view; non-personalized estimates on share previews and emails.
3. Validation with real usage data
Defining ground truth is the hardest part of this problem. Raw time-on-page is heavily biased: people leave tabs open, jump to a specific section, or read across multiple sittings.
Construct active reading time from client signals:
- Count elapsed time only when the tab is focused and visible, and the user has been active (scroll, mouse, or keystroke) within the last ~30 seconds.
- Track viewport progress: maximum scroll depth and dwell time per visible content block.
- Define a completed read as reaching ~90% of the document with dwell distributed across the document — not a single jump to the bottom.
- Exclude: the author's own sessions, editing sessions, and documents under ~50 words.
Separate skims from reads. A session where estimated reading speed exceeds ~2.5× baseline is a skim, not a read. Report both populations; do not silently discard skims. The feature promises reading time, so evaluate primarily against true reads.
Offline evaluation:
- Metric: median absolute percentage error and the fraction of completed reads where the prediction is within ±25%.
- Check calibration per slice: language, document length bucket, device type, image-heavy vs text-only. Mobile readers are typically 15–20% slower; long documents show more fatigue and increased skimming.
- V1 must beat the V0 heuristic on every major slice, not only overall.
Online evaluation:
- A/B test on label presence to measure engagement with shared documents and time-to-first-scroll.
- Optional lightweight feedback prompt ("Was this estimate about right?" / "Too short" / "Too long") on a small sample.
- Retrain on a weekly cadence; monitor for drift as document-type mix shifts over time.
Privacy: Collect only aggregated, sampled, de-identified timing signals. The feature vector sent to the backend is numeric (word count, image count, etc.) — never raw text. Respect enterprise admin and data-residency settings. Offer an opt-out. Raise this point unprompted; it is expected at this level.
4. System design
Client (web and mobile): Compute features from the in-memory document model and evaluate the estimate locally in under 1ms using coefficients from a cached config. Recompute lazily on edits, debounced by ~5 seconds. Render the header label and the "time remaining" variant based on content below the current viewport. Emit sampled telemetry: session ID, active-time segments, scroll depth, and the numeric feature vector — no text.
Backend:
On each save, a lightweight async worker computes and stores {revision_id, est_seconds, model_version} in document metadata. This is what Drive listings, share emails, and file-browser previews read without opening the document. A config service delivers model coefficients and experiment flags to clients.
Data pipeline:
- Telemetry flows into a streaming ingest queue, then into a short-retention raw event store.
- A batch job sessionizes events, applies the active-time and completed-read rules, joins in document features, and writes a training table of
(features, observed_active_time). - Training runs weekly. Evaluation gates on per-slice metrics before a canary pushes new coefficients through the config service.
Key trade-off — client vs server computation: The client gives freshness and zero marginal cost. The server is needed for surfaces where the document is not open. Run both using the same model version, sourced from the same config. If they disagree by more than a few seconds, the server value was computed against an older revision; prefer the client value when the document is open.
5. Success metrics
Primary: Share of readers for whom the estimate was within ±25% of observed active reading time (target: >70%).
Engagement proxy: Click-through rate on shared-document links increases after label exposure (measured in A/B test).
Author utility: Reduction in average document length in contexts where authors see the estimate while editing (signals they're using it for calibration).
Guardrails:
- P99 client-side computation time < 5ms; server-side worker adds < 50ms to save latency.
- No regression in document load time.
- User opt-out rate stays below a low threshold (e.g., <2%); a spike signals a trust problem.
- Monitor prediction bias by language and document type; if any slice's error exceeds ±40%, trigger a retraining.
Common mistakes to avoid
- Treating raw session duration as ground truth without addressing tab-switching, skimming, or multi-sitting reads.
- Proposing a sophisticated ML model before justifying why the heuristic is insufficient.
- Forgetting that the estimate must appear in surfaces where the document is not open — this forces a server-side path.
- Omitting privacy considerations entirely, or mentioning them as an afterthought.
- Optimizing for mean error without checking calibration per slice; a model that is accurate on average but wrong for all non-English documents is not shippable.