Loading section...
System Design: Real-Time Metrics Aggregation with Distributed Prefix Sums
Concepts: pyDistributedPrefixSum, pyMetricsSystem, pyShardedQuery
The system design version of the prefix sum problem goes like this: 'Design a system that can answer: what was total revenue between timestamps T1 and T2, with sub-millisecond latency, on a dataset that is being written to continuously.' This is a staff-level DE system design question. The answer has three layers: the algorithm (prefix sums), the data structure (pre-aggregated time buckets), and the distributed architecture (how you extend prefix sums across shards). Most candidates get the algorithm right and fumble the architecture. This section covers all three layers. Single-Machine Design First Distributed Architecture: Prefix Sums Across Shards When the data volume exceeds a single machine, you partition the event stream across N shards. Each shard maintains its own prefix sum array