Design an Incremental Checking Backend for Millions of Open Documents
Last updated: November 29, 2026
Quick Overview
Design the backend that receives text deltas from browser extensions, desktop apps and mobile keyboards, runs spelling, grammar and tone checks only on the changed parts, and streams suggestions back within a few hundred milliseconds of the user pausing.
Grammarly
November 29, 20260
0
0 solved
Design the backend that receives text deltas from browser extensions, desktop apps and mobile keyboards, runs spelling, grammar and tone checks only on the changed parts, and streams suggestions back within a few hundred milliseconds of the user pausing.
This is the core of Grammarly's product: tens of millions of daily users each have open documents that change every keystroke. The interviewer looks for a delta-based protocol instead of resending whole documents, paragraph-level caching, session affinity, and a clear latency budget.
What the Interviewer Expects
- Use a stateful session per document with deltas over a WebSocket, not full-text POSTs
- Re-check only dirty paragraphs or sentences and cache results by content hash
- Give a concrete latency budget split across network, queue and models
- Handle stale results by versioning documents and rebasing suggestion offsets
- Plan capacity and graceful degradation when GPU-backed models saturate
- Address privacy: retention, encryption, enterprise data isolation
Key Topics to Cover
How to Approach This
- Start by clarifying functional and non-functional requirements with the interviewer.
- Estimate the scale: QPS, storage, bandwidth. This drives your design decisions.
- Draw a high-level architecture first, then deep dive into 1-2 critical components.
- Discuss trade-offs explicitly (e.g., consistency vs availability, SQL vs NoSQL).
- Address failure scenarios, monitoring, and how the system handles 10x traffic spikes.
Possible Follow-up Questions
- How do you rebalance sessions when a gateway node dies mid-document?
- A 40-page document is pasted at once. What changes?
- How would you roll out a new grammar model to 5% of sessions safely?
- Where would you cache, and what is the hit rate you would expect?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Functional: open a document session, apply deltas, return suggestions (span, category, replacement, explanation), accept or dismiss feedback. Non-functional: p95 under 300 ms from typing pause to unde...
High-Level Design
Client debounces keystrokes (about 150 ms) and sends {doc_id, base_version, ops} over a WebSocket. An edge gateway terminates TLS and routes by doc_id with consistent hashing to a **session servic...