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, analzes this data.

•The volume can't fit on a single disk
•The volume can't be handeled by a single server
•Messages can come out of order (End event can come before start event)


Supported APIs:

1startEvent(event_id, timestamp) 2endEvent(event_id, timestamp) 3getOngoingEvents(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:

1select count(*) 2from events 3where 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