Build a Client SDK Event Batcher With Retry and Backoff

Last updated: November 29, 2026

Quick Overview

Write the core of an analytics SDK tracker that queues events, flushes a batch when it reaches a size limit or a time limit, retries failed uploads with exponential backoff, and keeps memory bounded when the device is offline.

Mixpanel
Software Engineering Fundamentals
Software Engineer
Mixpanel
November 29, 2026
Software Engineer
Technical Screen
Software Engineering Fundamentals
Easy

0

0

0 solved


Write the core of an analytics SDK tracker that queues events, flushes a batch when it reaches a size limit or a time limit, retries failed uploads with exponential backoff, and keeps memory bounded when the device is offline.

Mixpanel's JavaScript and mobile SDKs batch track calls before sending them to the ingestion API, and a bug here either loses data or drains a user's battery. The screen checks clean state handling, testability (injected clock), and sensible failure policy.

What the Interviewer Expects
  • Flush on size or age, whichever comes first
  • Never remove events from the queue until the send succeeds
  • Exponential backoff with a cap, and a retry limit
  • Bounded queue with an explicit drop policy and a counter
  • Inject the clock and transport so the logic is unit-testable
Key Topics to Cover
batching
exponential backoff
retries
bounded queues
testability
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • How do you persist the queue across app restarts and avoid sending a batch twice?
  • The server returns 413 for an oversized batch: what should the client do?
  • How would you flush reliably when a browser tab is closing?
  • Why add jitter to the backoff?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements

track(event) enqueues. A flush happens when the queue holds max_batch events or the oldest unsent event is max_wait seconds old. On failure, wait 2, 4, 8 seconds and so on (capped at 60) before ...

High-Level Design

State: queue, timestamp of first unsent event, retry_at, consecutive failure count, dropped counter. track appends and calls tick. tick (also driven by a timer) flushes when allowed. flush s...


Submit Your Answer
Markdown supported

Related Questions