KatInterview

Real-Time Location Aggregation System with Consensus Protocols

System DesignModel answer
HardModel answerSystem Designstreamingdistributed-systemsconsensus

Last updated

Build a system that aggregates streaming location data into grid cells, surfaces high-activity regions, and compare distributed consensus approaches.

You need to design a system that processes real-time location updates from millions of mobile users, aggregates them into geographic grid cells, and identifies the most active regions.

Part 1: System Design

Your system should:

  • Accept continuous location streams (latitude, longitude, timestamp, availability status) from mobile clients via persistent connections
  • Divide the geographic area into a grid and track which cells have the most active, available users
  • Provide an API to retrieve the K cells with the highest user counts, either globally or filtered by geographic region
  • Push live updates to monitoring dashboards and client applications

Part 2: Consensus Algorithms

Explain how Paxos and Raft solve the distributed consensus problem. What are the fundamental differences in their approach, and when would you choose one over the other?

Context:

  • This is an analytics use case where approximate counts are acceptable
  • Availability is more important than perfect consistency
  • The system should handle network partitions and server failures gracefully

Design the architecture, data model, APIs, and key algorithmic choices. Discuss trade-offs, scalability bottlenecks, and how consensus fits into the overall system.

Hints

Hint 1

Consider how to avoid counting the same user multiple times when they send frequent location updates, and what happens when they move between cells

Hint 2

Partitioning strategy matters: should you shard by user ID or by geographic region? Each choice affects how you compute rankings

Hint 3

For consensus algorithms, focus on the sequence of message exchanges and how each protocol handles leader election and log replication differently