Low Level Design: Cursor Sharing Service

Cursor State

{
  user_id,
  user_name,
  color,
  position: { line, col }  // for text, or { x, y } for canvas
  selection: { anchor, head },
  last_updated
}

Ephemeral Storage (Redis)

Cursor state stored only in Redis, not DB.

HSET cursors:{doc_id} user_id {serialized_cursor_state}
EXPIRE cursors:{doc_id} 30s  -- refreshed on each cursor move

Broadcast

Cursor move event → publish to Redis channel doc:{doc_id}:cursors → all WebSocket nodes push to connected clients.

Debounce: client sends cursor updates at most every 50ms.

Awareness Protocol

On join: client fetches all active cursors (HGETALL cursors:{doc_id}) and subscribes to channel.

On disconnect: remove user from hash (HDEL) → broadcast cursor-leave event.

Color Assignment

Deterministic color from hash of user_id (16 distinct colors).

UI Features

Selection

Highlight range in collaborator color.

Name Tag

Floating label near cursor showing user name.

Ghost Cursor

Show last known position faded when user is idle (no movement in 10s).

See also: Netflix Interview Guide 2026: Streaming Architecture, Recommendation Systems, and Engineering Excellence

See also: Atlassian Interview Guide

See also: Meta Interview Guide 2026: Facebook, Instagram, WhatsApp Engineering

Scroll to Top