Design an active user counter for a map viewport
PremiumReal-timeMedium
- Redis GEO
- GEOSEARCH
- Geohash
Quick answer
This real-time interview question asks you to design an active user counter for a map viewport. Aim for a design that delivers updates to many users with low delay, then explain connections, fan-out, ordering and trade-offs. Interviewers want to see how you keep latency low, handle reconnects and stay correct under load.
The problem
Design an active user counter for a map viewport: as a person pans or zooms a map, the app shows how many active users are inside the visible area, like a live people-nearby layer in a social or ride app. The hard part is answering 150,000 viewport queries a second while 2 million users keep moving.
Users share their location by sending heartbeats. Viewers only ever see a number for the area on screen, never where anyone is.
What must an active user counter for a map viewport do?
- Count on pan and zoom: When the viewport changes, the app gets the number of active users inside the visible box within 300 ms.
- Live while still: A map left open gets a fresh count at least every 5 seconds.
How well must it do it?
- Low latency: Viewport queries take under 100 ms at p99 on the server.
- High query volume: The system holds 150,000 viewport queries per second at peak.
What scale should you design for?
Use these numbers in your estimates.
The scale numbers unlock with this questionUnlock
Key concepts
- Redis GEO
- GEOSEARCH
- Geohash
- WebSocket
- Viewport queries
- Heartbeats
How you’ll practise
- Requirements
- Estimate
- Connections
- Message flow
- Delivery guarantees
- Wrap-up
Lala, personalized to you, gives a hint when you ask and reviews your design when you are ready.
What do interviewers look for?
In any real-time design round.
- Clarifies latency, ordering and delivery guarantees
- Chooses a connection model with reasons
- Explains fan-out to many receivers
- Handles reconnects, missed messages and duplicates
- Plans for hot spots and sudden traffic spikes
- States trade-offs between consistency and speed
Questions people ask about this interview question
- Which design type is this question?
- It is a real-time question. You design an active user counter for a map viewport and explain your choices the way you would in an interview.
- Is this question asked at entry level?
- It is marked Medium. Entry-level engineers can practise it, but it expects you to reason about requirements and trade-offs, not only list components.
- What should I cover first?
- Start with who sends and receives updates, how fast they must arrive and what order matters. Agree on scope with the interviewer before you design anything.
- Can I practise it for free?
- It is a premium question. Sign up and unlock it once for 10 credits; it then stays unlocked. When you finish, Lala, your personalized AI mentor, can review your design for 30 credits.
Related questions
Updated · Written by the SevyDevy team