Technical Interview Questions

Lark Real-Time Collaboration with CRDTs

"How would you implement real-time collaborative document editing for Lark (飞书), ensuring consistency when hundreds of users edit simultaneously?"

Why Interviewers Ask This

Lark is ByteDance's flagship enterprise product competing with Google Workspace and Microsoft 365. Real-time collaboration is its core differentiator. This question tests your knowledge of distributed systems fundamentals — conflict resolution, eventual consistency, and latency optimization — in a product context ByteDance cares deeply about.

How to Answer

  1. 1

    Compare OT (Operational Transformation) vs. CRDT (Conflict-free Replicated Data Types) and explain why CRDTs are increasingly preferred for their simpler conflict resolution guarantees.

  2. 2

    Describe the document model: a tree of blocks (paragraphs, tables, images), each node containing a CRDT-based text sequence.

  3. 3

    Explain the sync protocol: local edits applied immediately, sent to server via WebSocket, server merges and broadcasts to other clients.

  4. 4

    Address practical concerns: undo/redo with CRDT, cursor/selection awareness, offline editing and reconnection sync.

Sample Answer

I would use a CRDT-based approach, specifically a variant of Yjs or a custom RGA (Replicated Growable Array) for text sequences. Each character gets a unique ID composed of a client ID and a logical clock, ensuring deterministic merge ordering without a central authority. The document is modeled as a tree of CRDT nodes — each paragraph is an RGA, tables are CRDT maps of cell references, and rich-text formatting uses a mark-based approach where formatting spans are intervals attached to character IDs. For the sync layer, clients connect via WebSocket to a collaboration server. Local edits are applied optimistically to the client state and sent as delta operations. The server merges incoming deltas using the CRDT merge function and broadcasts the merged state to all connected clients. For offline support, clients accumulate local operations and sync on reconnection — the CRDT guarantees convergence regardless of operation ordering. Awareness features like cursor positions and selections are broadcast separately via a lightweight presence channel with 100ms throttling to reduce network overhead.

Pro Tips

  • Know the difference between OT and CRDT — OT requires a central server for transformation, while CRDTs can merge independently.

  • Mention Yjs or Automerge as real-world CRDT libraries to show practical awareness.

  • Discuss the memory overhead of CRDTs (tombstones for deleted characters) and garbage collection strategies.

Frequently Asked Questions

What is the main advantage of CRDTs over OT for collaborative editing?

CRDTs guarantee convergence by construction — any ordering of operations produces the same final state. OT requires a central server to transform operations, creating a single point of failure and making offline editing harder to implement.

How do you handle cursor positions in a CRDT-based editor?

Cursors are represented as relative positions between two character IDs rather than absolute offsets. This way, when other users insert or delete text, the cursor position remains semantically correct without explicit transformation.

Worried About Going Blank in Your Interview?

HireMe AI listens to your interview in real-time, detects questions, and generates instant answer suggestions — so you never freeze up again.

Try HireMe AI Free