Telemetry Pipeline Design for High-Frequency Robotics Fleet Data
System DesignModel answerLast updated
Design an end-to-end pipeline to ingest, validate, store, and query multi-modal sensor streams from a large fleet of autonomous robots at 20 GB/s aggregate throughput.
Scenario
A company operates a large fleet of autonomous robots in the field. During every mission, each robot continuously records telemetry from several onboard sensors: an inertial measurement unit (IMU) running at high frequency, GPS fixes, motor encoder counts, and perception metadata. Both real-time operations teams and offline simulation engineers depend on this data — to detect anomalies as they happen, replay missions for debugging, and compute derived behavioral statistics.
You are asked to design the platform that handles this data end-to-end: from the moment a robot generates a sensor reading to the moment an engineer queries a specific time window weeks later.
Requirements
Functional
- Ingestion: Accept both live streaming telemetry from active robots and bulk log file uploads when robots return to base. Both paths land in the same downstream storage.
- Validation: Detect and handle schema violations, clock synchronization drift, missing timestamps, dropped measurement sequences, and out-of-order samples — without halting the overall pipeline.
- Storage: Retain raw, unmodified logs indefinitely for compliance and replay purposes. Also maintain a normalized, indexed representation for fast analytical queries. Support pre-computed rollups at multiple time resolutions.
- Querying: Expose an API that returns all samples for a given robot and sensor channel within an arbitrary time range
[t_start, t_end], at either full fidelity or a specified downsampled resolution (for example, 100 Hz IMU reduced to 1 Hz averages). - Derived Metrics: Continuously compute windowed statistics — acceleration spikes, abrupt decelerations, positional drift — with results available in near real-time.
Non-Functional
- Scale: 2,000 active robots, each producing roughly 10 MB/s of telemetry (video and point cloud excluded), for a peak aggregate of approximately 20 GB/s.
- Alert latency: Validation failures and safety-relevant events must be flagged within 5 seconds of the sensor reading.
- Query latency: A range query spanning one hour of a single channel must return in under 2 seconds.
- Durability: No raw telemetry may be permanently lost once recorded on the robot.
What Your Answer Should Cover
- Architecture overview — the edge-to-cloud boundary, the streaming backbone, validation workers, and the downstream storage sinks.
- Storage strategy — which engine is appropriate for raw files, hot time-series data, and long-retention analytical rollups, and why they are separate.
- Validation design — specific checks, how malformed records are handled without blocking good data, and how the 5-second alert budget is met.
- Query and API design — how the data model enables fast time-range queries, how resolution routing works, and how write hotspots are avoided.
- Productionizing AI-generated code — how you would safely integrate, test, and deploy parser or aggregation logic that was initially drafted by an AI coding assistant.
There is no single correct topology. Justify your choices and call out the trade-offs.
Hints
Hint 1
Start by sizing the system before drawing any boxes. 2,000 robots × 10 MB/s drives every subsequent decision — Kafka partition count, storage tier sizes, and query index granularity all follow from that number.
Hint 2
Raw bytes and parsed records should flow through separate, independent paths. If your parser has a bug, you need to be able to replay from the original bytes without any data loss. Ask yourself: what is the true zero-loss anchor in this system?
Hint 3
For time-range queries to meet the 2-second SLA, you need to think about key design carefully. If your primary sort key starts with timestamp, all current writes land on the same node. What prefix prevents that hotspot while still enabling efficient range scans?
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
1. Size the System First
Before sketching any components, convert the prompt into concrete numbers. Interviewers use this to check whether you can reason from first principles.
- Ingestion rate: 2,000 robots × 10 MB/s = 20 GB/s at peak. With replication factor 3 in the streaming layer, brokers absorb roughly 60 GB/s of writes.
- Daily volume: Assuming robots are active 8 hours/day: 20 GB/s × 28,800 s ≈ 576 TB/day of raw data. After columnar encoding and compression (zstd), normalized data typically shrinks 3–5×.
- Query payload: One IMU channel at 100 Hz over one hour = 360,000 samples. At ~50 bytes each, that is about 18 MB — easily returned in under 2 seconds if it sits in a few contiguous partitions. The same window at 1-second resolution is 3,600 rows.
Key clarifying questions to ask: Does "zero loss" apply from the moment of capture on-robot, or from first cloud acknowledgment? (Answer: from capture — the robot must buffer locally.) Which channels need real-time alerting? How long is raw data retained?
2. High-Level Architecture
Robot (local SSD ring buffer, writes to MCAP/bag format)
├─ live path: gRPC/QUIC stream → Ingest Gateway → Kafka (raw topic)
└─ bulk path: resumable upload → Object Store (raw/, immutable)
Kafka raw ──► Raw Archiver ──────────────────► Object Store (checksummed, append-only)
└──► Parse & Validate (Flink) ─────► Kafka normalized | Kafka DLQ
├─► TSDB (hot, full fidelity, 7–14 days)
├─► Rollup jobs → TSDB + Parquet
├─► Feature/alert engine → Alerts
└─► Iceberg/Parquet lake (long retention)
Query API → router: TSDB (recent) | Parquet (older) | Object Store (raw replay)
The critical design principle: two independent paths. Raw bytes are archived without touching a parser. Parsing runs as a separate consumer downstream. A parser bug can therefore never corrupt or lose raw data — you fix the bug and replay from the object store.
Edge buffer as the zero-loss anchor. The robot writes every record to local storage first. It deletes a chunk only after the bulk upload's SHA-256 matches the server-side checksum. The live stream is best-effort for low-latency alerting; the bulk upload is authoritative.
3. Data Model and Storage Strategy
| Tier | Engine | Contents | Partitioning |
|---|---|---|---|
| Raw | Object store with object lock + cross-region replication | Original MCAP files, archived stream segments | raw/{robot_id}/{date}/{session_id}/{seq}.mcap |
| Hot time-series | ClickHouse or TimescaleDB | Normalized samples, full fidelity | Partition (robot_id, topic, YYYY-MM-DD-HH); sort (robot_id, topic, ts_ns) |
| Rollups | Same TSDB + Parquet | min, max, mean, count, sum, sumsq at 1s / 10s / 1m | Same keys plus resolution column |
| Analytical lake | Parquet on Iceberg | All normalized data, long retention | Partition by date, topic; cluster by robot_id, ts |
Normalized row schema: robot_id, session_id, topic, ts_corrected (int64 ns), ts_sensor, seq_no, payload columns, quality_flags (bitmask), parser_version.
Rollup structure: store count, sum, sumsq, min, max rather than just averages. This lets coarser resolutions compose exactly from finer ones (1m is built from 10s, 10s from 1s), and variance falls out of sumsq without re-scanning raw data.
Write hotspot prevention: a sort key that leads with timestamp puts all current writes on one shard. Leading with robot_id (or a hash of it) spreads writes evenly across nodes while still enabling efficient scans per robot per time window.
4. Validation and Quality Framework
Validation runs as keyed Flink operators, one state machine per (robot_id, topic). A 2-second event-time watermark bounds late arrival.
| Check | Detection rule | Action |
|---|---|---|
| Schema | Decode against registered schema version (Protobuf / ROS msg def) | Send to DLQ with raw bytes + error; pipeline continues |
| Dropped measurements | Gap in seq_no, or Δt > 1.5 × expected period | Emit a synthetic gap record; flag the window |
| Missing timestamp | Null or zero sensor_ts | Impute from logger_ts; set flag TS_IMPUTED |
| Out-of-order | ts < last seen ts for this stream | Re-order within the watermark window; flag if unresolvable |
| Clock drift | ` | sensor_ts − logger_ts |
| Physical plausibility | |accel| > 20g, NaN values, GPS jump exceeding v_max·Δt | Flag; raise an alert if the condition is sustained |
Core principle: flag, never silently drop. Every record lands somewhere — either the normalized table or the DLQ — with enough metadata to audit it later.
Meeting the 5-second alert budget: edge-to-Kafka is under 1 second; Flink processing plus the 2-second watermark adds roughly 2–3 seconds. Alerts fire from the stream, never from a downstream database query.
Derived features as sliding window operators:
- Jerk spikes: derivative of acceleration exceeds threshold over a 200 ms window
- Abrupt stops: deceleration > 0.5g while encoder-derived speed is dropping
- Positional drift: IMU + encoder dead-reckoning diverges from GPS by more than a configurable distance over a 10-second window
5. Query and API Design
GET /v1/robots/{robot_id}/topics/{topic}/samples
?t_start=&t_end=&resolution=raw|1s|10s|1m&fields=accel_x,accel_y
&page_token=
GET /v1/sessions/{session_id}/raw?t_start=&t_end=
→ signed object-store URLs for the relevant MCAP chunks
Resolution routing: if the caller omits a resolution, the router picks the coarsest pre-computed rollup that still yields at least N points (typically 2,000–5,000 for a visualization). Recent data is served from the TSDB; older data comes from Parquet with partition pruning on (date, topic, robot_id).
A 1-hour query touches 1–2 hour-level partitions for a single (robot, topic) key, so it is a contiguous sorted scan rather than a scatter-gather across the entire table. For full-fidelity pulls, stream results as Arrow batches or via gRPC server-side streaming rather than materializing the full result in memory.
6. Productionizing AI-Generated Code
Treat AI-drafted parser or aggregation code as an untrusted contribution subject to stricter review than typical internal code.
Write the spec first, then generate. Define the contract yourself: input schema, output schema, units, behavior on malformed input, and expected byte-for-byte output for known inputs. The AI implements against that spec; you own the spec.
Differential testing against a reference. For a sensor decoder, compare output sample-by-sample against the official SDK decoder or an existing trusted implementation on a corpus of real logs. Any divergence is a blocking failure.
Property-based testing. Use hypothesis-style random fuzzing to feed the parser arbitrary byte sequences, truncated buffers, and schema-mismatched payloads. It must never crash, never silently produce wrong output, and always write malformed input to the DLQ.
Performance profiling before merge. Parse a representative 1-hour log file and measure throughput. An ingestion worker processing 10 MB/s cannot afford a parser that bottlenecks at 8 MB/s.
Shadow deployment. Run the new code in parallel with the current implementation for one or more days. Compare output counts, field distributions, and quality flag rates. Promote only when metrics match within an agreed tolerance.
Rollback readiness. Because raw bytes are always preserved, a bad parser version can be rolled back and the affected window replayed with the corrected version. Track parser_version in every normalized row so you can identify and re-process affected records without re-processing everything.
Common mistake: treating AI output as correct because it looks plausible. Parser bugs on edge-case byte sequences are subtle and often only surface on production traffic. The differential test corpus and shadow deployment are what actually catch them.