System Design | Uber | SSE

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2023-04-04Added By Anonymous
Source: Link

Company: Uber

Role: Senior Software Engineer, Staff Software Engineer

Interview Stage: Onsite


Original Post Content:


Hi,


I was asked the following question during the system design interview.


A system that injects messages from other services. Plus, analyzes this data.

- The volume can't fit on a single disk

- The volume can't be handled by a single server

- Messages can come out of order (End event can come before start event)


Supported APIs:

startEvent(event_id, timestamp)

endEvent(event_id, timestamp)

getOngoingEvents(timestamp)


These startEvent and endEvent endpoints basically get an update from an event. Therefore, they need to store these timestamps. On the other hand, getOngoingEvents is a read operation. It should return number of events that are started already but not ended yet.



I was thinking a K/V database to have a table like event_id, start_date, end_date. Where on each event if can create/update a/the record (constraint #3)


When calculating the getOngoingEvent, the query should look like this:

select count(*)

from events

where start_date < timestamp < end_date


I also mentioned a TimeSeries DB here instead of a K/V DB. However, I have not much idea of what to index and how TS DB's work much.


However, what's the best way to add sharding/indexing here? Any other thoughts or solutions are appreciated.

Comments