Design a sub-50ms real-time bidding feature pipeline
Tests merging batch historical and streaming data under sub-50ms latency. Strong answers use dual paths: batch backfills a KV store, streaming writes to an in-memory cache, serving merges both at request time. Red flag: one database without hot-cold split.
What's really being asked
The interviewer wants to see if you understand the tension between high-throughput batch historical data and low-latency streaming data in a mission-critical serving path. They are evaluating your ability to partition a problem into hot, warm, and cold paths, select appropriate storage systems by latency profile, and reason about consistency and freshness tradeoffs under a hard SLA. This is fundamentally about feature platform architecture, not just ETL.
The full answer
First, a dual-ingestion architecture. The batch path processes terabytes of historical click and conversion logs nightly or hourly, writing pre-aggregated user profiles to a low-latency key-value store such as Redis, Aerospike, or a cloud-native KV service with p99 read latency under 5 milliseconds. Second, a streaming path that ingests live impression and click events from Kafka or Pub/Sub, computes session-level aggregations in a stateful stream processor like Flink or Spark Streaming, and writes results to an in-memory cache with TTL eviction so that real-time features decay naturally. Third, a serving layer that performs parallel lookups to both stores and merges feature vectors in under 10 milliseconds, leaving headroom for network hops and model inference. Fourth, operational considerations including backfill strategies when the streaming job replays, feature versioning to prevent training-serving skew, and circuit breakers so that a cold store timeout does not blow the 50 millisecond budget.
The mistakes people make
A single-database design such as dumping everything into BigQuery, Snowflake, or Postgres and querying it per bid request. These systems have query latencies measured in seconds or hundreds of milliseconds, which instantly fails the SLA. Another red flag is ignoring the merge step entirely and assuming one storage system can handle both batch and streaming optimally. Candidates also err by proposing heavy serialization formats like JSON or XML at serving time instead of flatbuffers or protobuf, adding unnecessary parse overhead. Finally, neglecting to mention TTLs or windowing for streaming features leads to unbounded memory growth and stale data.
What usually comes next
How do you handle late-arriving events in the streaming path without corrupting the session state? What is your strategy for backfilling a new feature into the key-value store without impacting serving latency? How do you ensure exactly-once semantics for billing-related features versus at-least-once for coarse aggregations? What happens when the in-memory cache evicts a hot key during a flash sale or traffic spike? How do you monitor and alert on end-to-end feature freshness?
A concrete example
Imagine a user who has purchased running shoes in the past. The batch pipeline has precomputed a historical category affinity vector and stored it under the user ID in Aerospike with a 24-hour TTL refresh. During the current browsing session, the user clicks three ads for trail running gear within two minutes. The streaming Flink job increments a real-time trail-running intent score and writes it to Redis with a 5-minute TTL. When the ad exchange receives a bid request, the serving microservice issues parallel asynchronous GETs to Aerospike and Redis, merges the vectors into a single 200-dimensional feature payload using protobuf, and passes it to the model in 12 milliseconds total.
Interview question
Why is it architecturally necessary to keep batch historical features in a KV store while maintaining session-level streaming features in a separate in-memory cache?
- a.The batch path produces terabyte-scale pre-aggregated profiles that are updated infrequently, while the streaming path handles high-velocity session events with natural TTL decay; a single storage system cannot optimize for both access patterns under the 50ms SLA.Correct
- b.KV stores provide strong consistency guarantees required for monetary billing features, whereas in-memory caches only support at-least-once semantics.
- c.Merging at the serving layer is only possible when the two stores use identical serialization formats such as Flatbuffers; mixing storage types would require expensive transformation logic.
- d.In-memory caches enforce schema-on-write, preventing training-serving skew, whereas KV stores use schema-on-read for backward compatibility with historical feature versions.
Why? this is the answer
The card states that batch and streaming data have fundamentally different latency, volume, and freshness requirements, so one storage system cannot handle both optimally without breaking the sub-50ms SLA. Distractor A sounds plausible because the follow-ups mention exactly-once semantics for billing, but the card never cites billing consistency as the reason for the dual-store split.
Just read this? Test yourself on what you have been reading.
Read the original → docs.cloud.google.com
- #mlops
- #data-engineering
- #system-design
- #low-latency
- #feature-store
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on mlops — each one lists the topics its interview covers.
See open roles