How do you measure retention on an event-driven data model with multiple daily sessions and billions of events?

Quick Overview

Asks how to measure cohort retention on a social platform from raw event logs with billions of rows and many sessions per user per day. Tests defining an active day, building an efficient daily-active table, choosing exact or approximate counting, and handling time zones, late events and identity.

How do you measure retention on an event-driven data model with multiple daily sessions and billions of events?

Role: Data Scientist

Category: Analytics & Experimentation

Difficulty: medium

Interview Round: Other

How is retention measured at social platforms using an event-driven data model, considering challenges like multiple sessions per day and billions of user events? Describe how you would go from raw event logs to a cohort retention number such as day-1 or day-7 retention, and what has to be handled along the way. ```hint Find the grain retention needs Ask what level of detail a retention number actually uses. Most of what the raw rows record never reaches it. ``` ```hint Look at the set operation Retention compares two sets of users. Think about which counting structures can intersect two sets accurately and which ones only estimate counts and unions well. ``` ### Constraints & Assumptions - Raw data is one row per event with `user_id`, `event_type` and a timestamp. There is no session table. - Volume is billions of events, and a single user can have many sessions and many events in one day. ### Clarifying Questions to Ask - Which events count as "active"? Does a passive app open or a background sync count? - Which retention definition is wanted: active exactly on day N, active on day N or any later day, or active within a window such as days 7 to 13? - Is the cohort new users by signup date, or everyone active on a given day? - Whose clock defines a day: UTC or the user's local time zone? - Do the numbers need to be exact for reporting, or are approximate counts fine for dashboards? ### What a Strong Answer Covers - A clear definition of an active user-day, the cohort, and the return window - How events are collapsed to one row per user per day, and why that handles multiple sessions - How the daily-active data is stored and partitioned so cohort joins stay cheap at this volume - When approximate counting structures are acceptable and where they lose accuracy - Data-quality issues that shift day boundaries or denominators, such as time zones, late events and identity stitching ### Follow-up Questions - How would you compute week-1 to week-4 retention for a cohort without rescanning raw events? - A logging change ships and day-7 retention drops by two points. How do you tell a real drop from an instrumentation change? - How do you backfill retention history when the definition of "active" changes? - How should cohorts whose day N has not arrived yet be shown on a retention chart?

Overview: Asks how to measure cohort retention on a social platform from raw event logs with billions of rows and many sessions per user per day. Tests defining an active day, building an efficient daily-active table, choosing exact or approximate counting, and handling time zones, late events and identity.

General logo
General
Nov 25, 2026
mediumData ScientistOtherAnalytics & Experimentation
0
0

How is retention measured at social platforms using an event-driven data model, considering challenges like multiple sessions per day and billions of user events?

Describe how you would go from raw event logs to a cohort retention number such as day-1 or day-7 retention, and what has to be handled along the way.

Constraints & Assumptions

  • Raw data is one row per event with user_id , event_type and a timestamp. There is no session table.
  • Volume is billions of events, and a single user can have many sessions and many events in one day.

Clarifying Questions to Ask Guidance

  • Which events count as "active"? Does a passive app open or a background sync count?
  • Which retention definition is wanted: active exactly on day N, active on day N or any later day, or active within a window such as days 7 to 13?
  • Is the cohort new users by signup date, or everyone active on a given day?
  • Whose clock defines a day: UTC or the user's local time zone?
  • Do the numbers need to be exact for reporting, or are approximate counts fine for dashboards?

What a Strong Answer Covers Guidance

  • A clear definition of an active user-day, the cohort, and the return window
  • How events are collapsed to one row per user per day, and why that handles multiple sessions
  • How the daily-active data is stored and partitioned so cohort joins stay cheap at this volume
  • When approximate counting structures are acceptable and where they lose accuracy
  • Data-quality issues that shift day boundaries or denominators, such as time zones, late events and identity stitching

Follow-up Questions Guidance

  • How would you compute week-1 to week-4 retention for a cohort without rescanning raw events?
  • A logging change ships and day-7 retention drops by two points. How do you tell a real drop from an instrumentation change?
  • How do you backfill retention history when the definition of "active" changes?
  • How should cohorts whose day N has not arrived yet be shown on a retention chart?