KatInterview

Building a Production Pipeline for Photo Object Recognition

System DesignModel answer
HardModel answerSystem Designml-system-designobject-detectionmodel-serving

Last updated

Design a scalable, reliable service that accepts images, runs object-detection models on GPUs, and returns labeled bounding boxes through sync and bulk APIs, with ML lifecycle and operations covered.

You are asked to design a platform that receives user-supplied images, finds the objects in them, and exposes the findings through APIs. For every image, the service returns bounding boxes, class labels and confidence scores.

Walk through the design end to end. Your answer should cover:

Requirements

  • Functional needs: what clients send (raw bytes, URL or storage reference), what they receive, how model versions are chosen, and how results are retrieved later.
  • Non-functional targets: accuracy, latency, throughput, availability and durability. State your assumptions with numbers.
  • Clarifying questions you would ask (fixed vs. custom classes, multi-tenancy, sensitive content, data residency).

Architecture

  • Ingestion, storage, preprocessing, model serving, and asynchronous workers and queues.
  • Interactive (single-image) versus bulk (many-image) request paths.
  • Metadata, dataset and model versioning.

Serving efficiency

  • Batching, GPU utilization, autoscaling and caching.
  • Capacity estimation.

Modeling and ML lifecycle

  • Single-stage versus two-stage detectors and when to use each.
  • Labeling and training pipeline, including how hard or uncertain examples are fed back.
  • Offline evaluation metrics and online monitoring.
  • A/B testing and safe rollout.

Operations and governance

  • Failure modes and backpressure.
  • Privacy and compliance.
  • Cost controls.
  • Rollback and blue-green or canary deployment.

Be explicit about the trade-offs you make and why.

Hints

Hint 1

Start by fixing numbers: daily volume, peak-to-average ratio, average image size and a latency budget for the interactive path. Everything else (GPU count, storage, queue sizing) follows from these.

Hint 2

Split traffic into two paths: a low-latency interactive path with small batches, and a throughput-oriented bulk path fed by a durable queue with large batches. Give each its own worker pool and scaling signal.

Hint 3

For the ML lifecycle, think in loops: versioned data plus code plus config produce a registered model; a frozen golden test set gates promotion; canary and shadow traffic validate in production; low-confidence and user-corrected samples flow back into labeling.