Design a Telemetry and Log Indexing Engine for Autonomous Vehicles
System DesignModel answerLast updated
Architect a scalable telemetry storage and indexing platform to capture, store, and query petabytes of high-throughput sensor logs efficiently.
You are tasked with designing a centralized data storage and retrieval infrastructure for a large autonomous vehicle (AV) fleet. Each operational vehicle generates a dense, continuous stream of raw sensor readings (high-resolution camera arrays, multi-channel LiDAR points, IMU telemetry, radar, and GPS) along with processed perception results (such as detected bounding boxes and path predictions). This yields approximately 500 MB per second per active vehicle.
Engineering teams need to perform fast, highly specific queries across the global fleet log collection. Typical search operations include finding precise vehicle timestamp ranges by metadata (e.g., "retrieve all instances where a vehicle navigated through a construction zone during rain") or by quantitative metrics (e.g., "identify video/LiDAR recordings where camera exposure noise exceeds a specified limit").
Key Requirements
- High Ingestion Throughput: Efficiently absorb and process continuous log streams from a fleet of thousands of operational vehicles.
- Targeted Retrieval: Enable sub-second to low-second range queries for specific vehicle IDs, sensor streams, and target timestamps without scanning unnecessary raw bytes.
- Structured & Attribute Search: Support granular filtering across high-cardinality metadata fields (e.g., location cells, weather conditions, perception labels, system flags).
- Cost Optimization: Design a long-term storage strategy that minimizes operational costs while maintaining searchability over extended time horizons.
Deliverables
- Back-of-the-Envelope Estimation: Quantify network bandwidth, daily/monthly storage volume, and financial impact.
- System Architecture: Outline the end-to-end data pipeline spanning on-vehicle collection, depot upload, and cloud processing.
- Storage & Indexing Blueprint: Define the data stores, indexing mechanisms, and catalog schemas to execute low-latency metadata queries and target file segment lookup.
- Data Lifecycle & Economics: Detail strategies for data retention, data reduction/triage, and storage tiering.
Hints
Hint 1
Calculate total raw bandwidth per vehicle: 500 MB/s equates to 4 Gbps. Continuous streaming via cellular is economically and technically impossible, necessitating local storage on NVMe SSDs with depot offloading.
Hint 2
Decouple raw payload retrieval from metadata filtering. Store heavy raw logs in object storage and light metadata in a specialized analytical engine.
Hint 3
Use a triaged retention policy: pin high-value clips (e.g., hard braking, disengagements, low-confidence perception events) while aggressively downsampling or dropping routine driving data.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
1. System Requirements & Scale Calculations
System Capacity Estimates
- Fleet Footprint: Assume 1,000 active vehicles operating 8 hours daily (scalable to 5,000+).
- Per-Vehicle Data Rate: $500 \text{ MB/s} = 4 \text{ Gbps}$.
- Daily Volume per Vehicle: $500 \text{ MB/s} \times 28,800 \text{ seconds} \approx 14.4 \text{ TB/day}$.
- Fleet Daily Intake: $1,000 \text{ vehicles} \times 14.4 \text{ TB} = 14.4 \text{ PB/day}$ (approx. $432 \text{ PB/month}$).
Network Constraints
- Cellular connections (5G/LTE) typically deliver 50–200 Mbps uplink under ideal conditions, whereas each car generates 4,000 Mbps.
- Conclusion: Complete real-time streaming of raw sensor payloads over cellular is impossible. Vehicles must write raw streams locally to removable NVMe arrays. Only low-bandwidth telemetry, critical alerts, and frame summaries (a few KB/s to MB/s) travel over cellular networks in real time. Full raw logs are ingested upon returning to maintenance depots using physical 10GbE/100GbE docking interfaces or physical drive swaps.
Financial Reality
- standard cloud object storage (at $\sim$20/\text{TB/month}$) costs approximately $$8.6\text{M/month}$ for $430\text{ PB}$.
- Storage cost is the dominant system constraint. Data reduction, selective archiving, and intelligent retention rules are mandatory.
2. API Design
Depot Ingestion Control API
POST /v1/uploads/sessions
Header: Authorization: Bearer <token>
Payload: { "vehicle_id": "AV-804", "drive_id": "drv_88392", "total_bytes": 15480000000000 }
Response: 201 Created { "upload_id": "upl_99301", "chunk_size_bytes": 536870912 }
PUT /v1/uploads/sessions/{upload_id}/chunks/{chunk_index}
Header: Content-Type: application/octet-stream, Content-SHA256: <hash>
Body: <Binary MCAP File Chunk>
Response: 200 OK
POST /v1/uploads/sessions/{upload_id}/commit
Response: 200 OK { "status": "INGESTED", "registered_chunks": 28800 }
Search & Retrieval API
GET /v1/search?start_time=1700000000&end_time=1700003600&event_type=DISENGAGEMENT&weather=RAIN&limit=50
Response: 200 OK
{
"matches": [
{
"vehicle_id": "AV-804",
"drive_id": "drv_88392",
"start_timestamp": 1700001200,
"end_timestamp": 1700001230,
"channels": ["cam_front", "lidar_top"],
"segment_url": "https://storage.provider.com/logs/AV-804/2023-11-14/chunk_04.mcap?signature=..."
}
]
}
GET /v1/logs/{vehicle_id}/bytes?start_time=1700001200&end_time=1700001230&channels=lidar_top
Response: 200 OK
{
"byte_ranges": [
{ "uri": "s3://av-logs/AV-804/2023-11-14/12/lidar_top.mcap", "offset_start": 1048576, "offset_end": 52428800 }
]
}
3. High-Level Architecture
[ On-Vehicle Sensors ]
│
├─► (Real-Time LTE) ──► [ Cellular Gateway ] ──► [ Kafka Metadata Topic ] ──► [ OLAP Engine ]
│ ▲
└─► (Local NVMe Storage) │
│ │
(Depot Return) │
│ │
▼ │
[ Depot Ingest Edge Node ] │
│ │
├─► [ Object Storage (S3/GCS) ] │
│ (Path: raw/vehicle_id/date/hour/channel.mcap) │
│ │
└─► [ Metadata Extractor Service ] ────────────────────────────────────────┘
│
▼
[ Relational Catalog (Postgres) ]
Path Components
- On-Vehicle Edge: Continuous logging writes into container formats (such as MCAP) in 60-second files. Each file contains internal header indices mapping message timestamps to exact byte offsets.
- Depot Ingestion (Heavy Payload Path): Vehicles plug into depot access points running high-throughput parallel upload daemons. Chunks are uploaded directly to Object Storage partitioned by
raw/{vehicle_id}/{yyyy-mm-dd}/{hh}/{channel_id}/{start_timestamp}.mcap. - Metadata Pipeline (Light Payload Path): Low-bandwidth streaming during transit plus post-ingest header inspection sends structured summaries into Kafka event streams.
- Query & Retrieval Layer: The user query evaluates attributes in the OLAP engine, fetches exact file byte bounds from the Metadata Catalog, and yields direct S3 signed HTTP byte-range URLs to the client.
4. Indexing & Storage Blueprint
To satisfy sub-second metadata queries alongside arbitrary point-in-time byte-level extractions, data management is split across three dedicated data engines:
+-----------------------------------------------------------------------------------+
| Search Request |
+-----------------------------------------------------------------------------------+
|
+-----------------+-----------------+
| |
v v
+-------------------------------+ +-------------------------------+
| 1. OLAP Metadata Store | | 2. Vector / Embedding Engine|
| (ClickHouse / StarRocks) | | (Milvus / Qdrant) |
| - Range scans on metrics | | - Semantic similarity |
| - Categorical tag filters | | - Visual perception embeddings|
+-------------------------------+ +-------------------------------+
| |
+-----------------+-----------------+
|
v
+-----------------------------------+
| 3. Relational Catalog |
| (PostgreSQL Transactional) |
| - Resolves segment IDs to paths |
| - Returns byte offsets & URLs |
+-----------------------------------+
Store 1: Relational File Catalog (PostgreSQL)
Tracks log file locations, integrity checksums, byte boundaries, and storage class locations.
CREATE TABLE log_chunks (
chunk_id UUID PRIMARY KEY,
vehicle_id VARCHAR(64) NOT NULL,
channel_id VARCHAR(32) NOT NULL,
start_time TIMESTAMPTZ NOT NULL,
end_time TIMESTAMPTZ NOT NULL,
s3_uri TEXT NOT NULL,
file_size_bytes BIGINT NOT NULL,
sha256_hash BYTEA NOT NULL,
storage_tier VARCHAR(16) NOT NULL, -- 'HOT', 'WARM', 'COLD'
is_pinned BOOLEAN DEFAULT FALSE
) PARTITION BY RANGE (start_time);
CREATE INDEX idx_chunks_lookup
ON log_chunks (vehicle_id, channel_id, start_time, end_time);
Store 2: Analytical Event & Signal Store (ClickHouse / StarRocks)
Used for fast filtered searches across aggregate statistics, perception events, and sensor diagnostics.
CREATE TABLE vehicle_telemetry_1s (
timestamp DateTime64(3),
vehicle_id LowCardinality(String),
geohash String,
speed_mps Float32,
disengagement_active UInt8,
lidar_noise_p95 Float32,
camera_drop_count UInt16,
detected_objects Array(LowCardinality(String)),
weather_condition LowCardinality(String)
) ENGINE = MergeTree()
PARTITION BY toYYYYMM(timestamp)
ORDER BY (vehicle_id, timestamp)
SETTINGS index_granularity = 8192;
-- Skip index to accelerate noise searches
ALTER TABLE vehicle_telemetry_1s ADD INDEX idx_lidar_noise lidar_noise_p95 TYPE minmax GRANULARITY 4;
Query Execution Flow
- Filtering: An engineer requests logs where
lidar_noise_p95 > 8.5aroundgeohash='9q8yy'. The query hits ClickHouse, scanning sorted columnar partitions in milliseconds to extract list of(vehicle_id, start_time, end_time). - Byte Mapping: The Query Gateway joins these tuples against PostgreSQL
log_chunksto get target file paths and internal byte offsets. - Fetching: The client reads the target raw data directly from S3 using HTTP
Range: bytes=start-endheaders, bypassing full file downloads.
5. Data Lifecycle & Cost Optimization
Retention Tiers
| Tier | Storage Medium | Time Window | Content Policy | Relative Cost |
|---|---|---|---|---|
| Hot | Standard Object Storage / Local NVMe | Days 0–14 | 100% full-fidelity raw sensor data | 100% |
| Warm | Infrequent Access (IA) Storage | Days 15–90 | Retain 100% metadata/summaries; raw streams downsampled | ~40% |
| Cold | Glacier Deep Archive | Day 90+ | Only pinned critical events preserved; rest expired | <5% |
Automated Triage and Selective Retention
Storing uncompressed sensor streams indefinitely is unsustainable. The system applies automated triage rules within the first 14 days of ingestion:
┌───────────────────────────────┐
│ Incoming Raw Ingest (100%) │
└───────────────┬───────────────┘
│
Is Event Pinned or Critical?
(Disengagements, Hard Braking,
Low-Confidence Perception)
│
┌────────────────┴────────────────┐
│ │
[ YES ] [ NO ]
│ │
▼ ▼
┌─────────────────────────────────┐ ┌───────────────────────────────┐
│ Retain 100% Raw Streams │ │ Downsample Sensor Data │
│ (±30s Window Around Event) │ │ - Cameras: 30 fps ──► 2 fps │
│ Move to Long-Term Cold Archive │ │ - LiDAR: Drop raw points, │
└─────────────────────────────────┘ │ keep bounding boxes │
│ Delete non-essential streams │
└───────────────┬───────────────┘
│
▼
┌───────────────────────────────┐
│ Expire Raw Data After 30 Days │
└───────────────────────────────┘
- Data Pinning Criteria: Events involving safety interventions, manual driver disengagements, collision alerts, unique weather conditions, or rare perception classes are flagged for long-term retention alongside a $\pm 30$-second contextual window.
- Aggressive Pruning: Routine driving data (90%+ of total volume) is retained at full fidelity for 14 days. If unpinned after triage, secondary video streams are downsampled (e.g., 30 FPS to 2 FPS), non-critical point clouds are discarded, and remaining assets expire after 30 days.
6. Trade-offs: Raw Data vs. Feature Vector Pre-processing
| Strategy | Pros | Cons | Recommendation |
|---|---|---|---|
| Raw Payload Storage (LiDAR PCD, PCAP, Video) | Allows retroactive execution of newly trained perception models and deep post-incident analysis. | Massive storage footprint and high network ingestion costs. | Mandatory short-term storage; selectively archive critical long-term segments. |
| Pre-processed Vectors / Feature Embeddings | Extremely compact; enables high-speed vector search (e.g., visual similarity search for "pedestrians with strollers"). | Irreversible data loss. Cannot re-run improved neural networks on historical scenes. | Compute globally on ingestion and store permanently alongside metadata. |
7. Common Pitfalls & Anti-Patterns
- Attempting Real-Time Raw Log Uploads over Cellular: Trying to stream multi-gigabit payloads over cellular networks leads to connection drops and extreme costs. Limit cellular communication strictly to low-bandwidth diagnostic events and frame metadata.
- Indexing Metadata in Standard Document Stores: Using traditional document stores like Elasticsearch for high-volume telemetry metadata can lead to massive JVM memory overhead and write amplification. Columnar OLAP databases (e.g., ClickHouse) compress numeric time-series data far more efficiently.
- Monolithic Storage Files: Saving continuous drive logs as single multi-gigabyte monolithic blobs forces expensive file downloads for short clip queries. Structuring containers (like MCAP) into fixed time chunks with index footers enables fine-grained range scans.