← Grammarly Interview Insights

Grammarly·Software Engineer·Onsite - System Design / Architecture·Senior

Senior
Jul 2026

Summary

System design round at Grammarly for a software engineer role. The whole thing was a deep dive into building a collaborative spreadsheet product from scratch, think Google Sheets but you have to justify every decision out loud.

Questions Asked (7)

Q1

Design an online spreadsheet service where multiple users can edit the same workbook simultaneously in real time.

System DesignTechnical Trade-offsData Modeling
Author's notes

This is a beast of a question.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements: scale, consistency needs, and key features. Then propose a high-level architecture using a client-server model with operational transformation or CRDTs for conflict resolution, and dive into data modeling, real-time communication, and scalability considerations.

Pro tip: Demonstrate awareness of trade-offs between consistency and latency, and mention how you would handle offline editing and conflict resolution. Also, relate to Grammarly's focus on real-time collaboration and correctness.

1. Clarify Requirements

Ask questions to understand scale (number of concurrent users, document size), consistency requirements (strong vs eventual), and key features (formulas, formatting, offline support).

2. High-Level Architecture

Outline components: clients, real-time communication layer (WebSockets), application servers, collaboration engine (OT/CRDT), and storage. Explain data flow.

3. Data Modeling and Conflict Resolution

Describe how to represent spreadsheet data (cells, formulas, dependencies) and how to handle concurrent edits using OT or CRDTs, including trade-offs.

4. Scalability and Reliability

Discuss scaling WebSocket servers, sharding workbooks, caching, and ensuring fault tolerance and persistence.

5. Trade-offs and Extensions

Summarize key trade-offs (e.g., consistency vs latency) and mention potential extensions like offline mode, version history, and permissions.

Key Points to Mention

  • Operational Transformation (OT) vs Conflict-free Replicated Data Types (CRDTs) for real-time collaboration
  • WebSocket for bidirectional real-time communication
  • Data model: sparse matrix of cells, formula dependency graph, and efficient updates
  • Consistency models: strong vs eventual consistency, and their impact on user experience
  • Scalability: partitioning workbooks, load balancing, and handling hot spots
  • Offline support and synchronization when reconnecting

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

How would you design the data model for workbooks, sheets, cells, and revision history?

Data ModelingSystem Design
Author's notes

I went with a cell-level revision log keyed by (workbook_id, sheet_id, row, col, version).

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the functional and non-functional requirements, such as expected scale, collaboration needs, and revision history granularity. Then propose a normalized relational schema for core entities (workbooks, sheets, cells) and a separate revision history table that captures changes with versioning. Discuss trade-offs between normalization and denormalization, and how to handle concurrent edits and efficient history retrieval.

Pro tip: Demonstrate awareness of real-world constraints by mentioning how you'd handle large sheets (e.g., sparse storage, chunking) and how revision history can be implemented using event sourcing or change data capture (CDC) to avoid performance bottlenecks.

1. Clarify Requirements

Ask about scale (number of users, cells per sheet), collaboration features (real-time editing), and revision history needs (how far back, granularity). This shows you don't jump to solutions without understanding the problem.

2. Define Core Entities and Relationships

Outline the main tables: Workbooks (id, name, owner, timestamps), Sheets (id, workbook_id, name, order), Cells (id, sheet_id, row, column, value, formula, format). Explain relationships and indexing strategies for efficient queries.

3. Design Revision History

Propose a revisions table (id, entity_type, entity_id, change_type, old_value, new_value, user_id, timestamp) or an event log. Discuss how to reconstruct past states and handle efficient retrieval of history.

4. Address Scalability and Performance

Discuss partitioning, sharding by workbook_id, caching, and sparse storage for cells. Mention how to handle large sheets and frequent updates without degrading performance.

5. Consider Trade-offs and Alternatives

Compare SQL vs NoSQL, normalized vs denormalized, and event sourcing vs snapshotting. Explain why you'd choose one approach based on requirements.

Key Points to Mention

  • Normalization vs denormalization for cells and sheets
  • Indexing strategies for fast cell retrieval by sheet, row, and column
  • Revision history implementation: event sourcing, change data capture, or audit tables
  • Handling concurrent edits and conflict resolution (e.g., operational transforms or CRDTs)
  • Scalability considerations: sharding, partitioning, and caching
  • Data integrity and consistency guarantees (ACID vs eventual consistency)

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

Walk through your API design for opening a session, fetching a sheet, submitting edits, subscribing to live updates, and catching up after a reconnect.

API & IntegrationsSystem Design
Author's notes

The reconnect catchup part tripped me up.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Structure your answer around the client-server interaction lifecycle, emphasizing how each API call supports real-time collaboration and resilience. Start with session establishment, then detail data fetching and mutation, and finally explain the subscription and reconnection strategy with a focus on consistency and conflict resolution.

Pro tip: Highlight the trade-offs between consistency and latency, and mention how you would use versioning or operational transforms to handle concurrent edits, showing you understand Grammarly's real-time collaborative editing challenges.

1. Session Initialization

Explain how a client opens a session: authenticate, establish a session ID, and negotiate capabilities (e.g., supported operations, protocol version). Mention using WebSocket or HTTP long-polling for the initial handshake.

2. Fetching a Sheet

Describe the API for retrieving a sheet: a GET request that returns the sheet content, metadata, and a version identifier. Discuss pagination or partial loading for large sheets.

3. Submitting Edits

Outline how edits are sent: a POST/PUT request with the edit operations, base version, and client-generated ID for idempotency. Explain how the server validates, applies, and broadcasts changes.

4. Subscribing to Live Updates

Detail the subscription mechanism: a WebSocket channel or server-sent events where the server pushes updates to all session participants. Mention how to handle ordering and deduplication.

5. Catching Up After Reconnect

Explain the reconnection flow: client reconnects, sends its last known version, and requests missed updates. Server responds with a delta or full snapshot if the gap is too large, ensuring consistency.

Key Points to Mention

  • Use of WebSockets for real-time bidirectional communication
  • Versioning and optimistic concurrency control to handle conflicts
  • Idempotency keys for edit submissions to avoid duplicate operations
  • Delta synchronization for efficient catch-up after reconnect
  • Authentication and authorization for session security
  • Scalability considerations: load balancing, pub/sub backends (e.g., Redis), and sharding

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q4

How do you handle conflict resolution when two users edit the same cell or insert rows and columns at the same time?

System DesignTechnical Trade-offsConflict Resolution
Author's notes

Row and column insertions are the sneaky hard part here.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements and constraints, such as real-time collaboration, offline support, and consistency needs. Then compare conflict resolution strategies like OT and CRDTs, explaining trade-offs in terms of complexity, scalability, and user experience. Finally, propose a concrete solution with a fallback mechanism and discuss how you would test and monitor it.

Pro tip: Acknowledge that perfect automatic resolution isn't always possible and that surfacing conflicts to users with clear UI can be a pragmatic choice. Mention that the best approach depends on product priorities, showing you balance technical purity with user needs.

1. Clarify Requirements

Ask about the expected scale, real-time vs. asynchronous collaboration, offline support, and consistency guarantees. This shows you don't jump to solutions without understanding the problem.

2. Compare Approaches

Discuss Operational Transformation (OT) and Conflict-free Replicated Data Types (CRDTs), highlighting their strengths and weaknesses for concurrent edits and structural changes like row/column insertion.

3. Propose a Solution

Recommend a specific approach (e.g., CRDTs for offline-first or OT for centralized real-time) and explain how it handles the given conflict scenarios, including merge semantics.

4. Address Edge Cases and Fallbacks

Describe how to handle conflicts that can't be auto-resolved, such as user notifications, version history, or manual merge options. Mention testing strategies like property-based testing and chaos engineering.

5. Discuss Trade-offs and Scalability

Summarize the trade-offs of your chosen approach in terms of latency, complexity, and infrastructure, and how it would scale with the number of users and document size.

Key Points to Mention

  • Operational Transformation (OT) and its central server requirement
  • Conflict-free Replicated Data Types (CRDTs) and their decentralized nature
  • Last-Writer-Wins (LWW) and its limitations for concurrent edits
  • Handling structural changes (row/column insertion) with CRDTs like RGA or Yjs
  • User experience considerations: conflict indicators, version history, and manual resolution
  • Testing strategies: simulation of concurrent edits, property-based testing, and monitoring

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q5

How would you handle persistence, snapshots, and recovery if a server crashes mid-session?

System DesignTechnical Trade-offs
Author's notes

Talked about write-ahead logging and periodic snapshots so you don't have to replay the entire op history on recovery.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the session model and consistency requirements, then propose a layered persistence strategy (e.g., write-ahead logging + periodic snapshots) with idempotent recovery. Discuss trade-offs between durability, latency, and cost, and how you'd validate recovery with chaos testing.

Pro tip: Tie your answer to Grammarly's real-time collaborative editing context: emphasize that snapshots must be consistent with the operation log and that recovery should be idempotent to handle duplicate replays safely.

1. Clarify requirements and failure model

Ask about session semantics (e.g., collaborative document editing), acceptable data loss window, and whether recovery must be automatic. Define what 'mid-session' means: crash of a single server, availability zone, or entire region.

2. Design persistence layer

Propose a write-ahead log (WAL) or append-only operation log for durability, combined with periodic snapshots to bound recovery time. Mention using a distributed store like Kafka or a database with strong consistency for the log.

3. Define snapshot strategy

Explain how snapshots are taken (e.g., every N operations or T seconds), stored (e.g., object storage), and versioned. Ensure snapshots are consistent with the log by recording the log offset at snapshot time.

4. Outline recovery process

Describe loading the latest snapshot and replaying subsequent log entries to reconstruct state. Emphasize idempotency: operations should be replay-safe, and recovery should handle partial writes or duplicates.

5. Address trade-offs and validation

Discuss trade-offs: snapshot frequency vs. recovery time and storage cost; synchronous vs. asynchronous persistence. Propose testing recovery with fault injection and monitoring recovery time objectives (RTO/RPO).

Key Points to Mention

  • Write-ahead logging (WAL) for durability and crash consistency
  • Periodic snapshots to reduce recovery time and log size
  • Idempotent operations and exactly-once processing semantics
  • Trade-offs between latency, durability, and cost (e.g., sync vs. async writes)
  • Recovery time objective (RTO) and recovery point objective (RPO)
  • Testing recovery with chaos engineering and fault injection

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q6

How would you approach formula recalculation when a cell that other cells depend on gets updated?

System DesignAlgorithms & Data Structures
Author's notes

I described a dependency graph and topological sort for propagating updates.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements and constraints, such as the scale of the dependency graph and performance needs. Then describe a dependency graph approach with topological sorting to determine recalculation order, and discuss optimizations like lazy evaluation and cycle detection. Finally, mention trade-offs and how you would handle edge cases.

Pro tip: Demonstrate awareness of real-world spreadsheet complexities like circular references and incremental updates, and tie your solution to Grammarly's need for efficiency and correctness at scale.

1. Clarify Requirements

Ask about the scale (number of cells, update frequency), performance requirements, and whether the system must handle cycles or errors. This shows you think before coding.

2. Model Dependencies

Represent cells as nodes in a directed graph where an edge from A to B means B depends on A. This allows efficient traversal and cycle detection.

3. Determine Recalculation Order

Use topological sorting to order cells so that each cell is recalculated only after all its dependencies. This ensures correctness and avoids redundant computations.

4. Optimize and Handle Edge Cases

Consider lazy evaluation (recalculate only when needed), incremental updates, and cycle detection (report errors). Discuss trade-offs between eager and lazy approaches.

5. Discuss Implementation and Trade-offs

Talk about data structures (adjacency lists, reverse dependencies), algorithms (DFS/BFS for topo sort), and how to scale (e.g., batching updates). Mention potential pitfalls like stale values.

Key Points to Mention

  • Dependency graph representation (directed graph, adjacency list)
  • Topological sorting for recalculation order
  • Cycle detection to prevent infinite loops
  • Lazy vs. eager evaluation strategies
  • Incremental updates and caching
  • Performance considerations for large-scale systems

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q7

How would you scale this system and keep latency low for users across different regions?

System DesignTechnical Trade-offs
Author's notes

Went with region-affinity for sessions, a central coordination layer for cross-region conflicts, and eventual consistency with strong consistency only for the op ordering within a session.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the system's current architecture, scale, and latency requirements, then propose a multi-region deployment with edge caching and data replication. Discuss trade-offs between consistency, cost, and latency, and how you would measure and iterate on performance.

Pro tip: Emphasize that latency is a user experience metric, not just a server metric—focus on reducing round trips and leveraging CDNs for static assets, while being pragmatic about data consistency trade-offs.

1. Clarify Requirements and Constraints

Ask about expected user distribution, read/write patterns, data consistency needs, and budget. This ensures your scaling strategy aligns with business goals.

2. Design Multi-Region Architecture

Propose deploying services in multiple regions close to users, using global load balancing to route traffic to the nearest healthy region.

3. Optimize Data Layer for Low Latency

Discuss data replication strategies (e.g., active-active or read replicas) and caching (CDN, edge, in-memory) to reduce database round trips.

4. Address Consistency and Trade-offs

Explain how you'd handle data consistency across regions (e.g., eventual consistency, conflict resolution) and the trade-offs with latency and cost.

5. Monitor, Measure, and Iterate

Outline a plan to monitor latency (e.g., p95, p99) per region, set SLOs, and continuously optimize based on real user data.

Key Points to Mention

  • CDN and edge caching for static and dynamic content
  • Multi-region deployment with geo-routing (e.g., latency-based routing)
  • Data replication strategies (active-active, read replicas) and consistency models
  • Caching layers (Redis, Memcached) and cache invalidation
  • Latency metrics (p95, p99) and SLOs
  • Trade-offs: cost vs. performance, consistency vs. availability

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.