Preparing your design workspace

Loading the problem and your latest saved attempt…

Design a Real-Time Anonymous Pixel Canvas

Design multi-canvas real-time drawing where anonymous users update one pixel at a time and all viewers converge through compact durable state.

Problem statement

For this exercise, assume a real-time application has multiple existing fixed-size canvases. Users are anonymous, and each operation changes exactly one in-bounds pixel. Clients attach an ephemeral operation identity so a retry returns the original result.

The service assigns a monotonic version per canvas; the higher accepted version determines the final color when concurrent operations target the same coordinate. A reconnecting viewer loads a compact snapshot and replays retained updates after the snapshot version.

Anonymous writes are admitted through bounded per-client and per-canvas limits and receive an explicit retry-later outcome when throttled. Treat each canvas as an isolation boundary for state and admission: failure or overload on one canvas must not corrupt another canvas.

A canvas may be 4K by 4K, so a design that persists one independent database row per pixel would create more than one million rows and is not acceptable as the primary snapshot model.

Focus on loading an existing canvas, applying and broadcasting pixel changes, reconnecting, compact persistence, deterministic same-pixel conflicts, and overload behavior. Canvas creation is outside scope. Do not add accounts, shapes, brush strokes, layers, image uploads, comments, moderation, or payments.

What to build

  1. An anonymous viewer can load a compact snapshot of an existing fixed-size canvas and resume from its exact canvas version.
  2. An anonymous user can idempotently update exactly one in-bounds pixel and receive the deterministic canvas version assigned to that operation.
  3. Connected viewers receive ordered pixel updates for one canvas and can recover through snapshot plus replay after disconnect or lag.
  4. Updates, versions, snapshots, subscriptions, admission limits, and failures remain scoped to the selected canvas across a multi-canvas deployment; throttled writes are rejected explicitly before mutation.

At scale

  • A fixed canvas may be 4K by 4K, which makes one independent database row per pixel an intentionally rejected primary snapshot representation.
  • Each source-defined write changes exactly one pixel, and the service supports multiple isolated canvases with anonymous participants.
  • For this exercise, concurrent bursts may target the same coordinate; write admission and fan-out must remain bounded without silently losing accepted operations.