Hourly p50 and p95 Feed Load Latency by Region in Pandas
Last updated: November 29, 2026
Quick Overview
Given one row per News Feed load with region, timestamp and latency, compute hourly p50 and p95 latency per region with sample counts, and flag hours with too few samples to trust. Rows with missing latency are excluded.
Meta
November 29, 20260
0
0 solved
Given one row per News Feed load with region, timestamp and latency, compute hourly p50 and p95 latency per region with sample counts, and flag hours with too few samples to trust. Rows with missing latency are excluded.
A pandas question for data scientists on Meta's performance team, who track tail latency because it drives engagement on slow networks. The interviewer looks for flooring to the hour, groupby with named aggregations, percentile semantics, and sample-size awareness.
What the Interviewer Expects
- Drop or separately count missing latencies
- Floor timestamps to the hour
- Use groupby with named aggregations for count and quantiles
- Flag low-sample hours
- Explain why you cannot average hourly p95s into a daily p95
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you compute a daily p95 correctly from hourly data?
- What quantile interpolation does pandas use and does it matter?
- How would you scale this to billions of rows?
- How would you compare p95 before and after a release?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
loads has columns region, ts (UTC Timestamps) and latency_ms. Some rows have NaN latency from aborted loads; I exclude them but would report the abort rate separately since aborts are often th...
Approach
Floor ts to the hour, group by region and hour, and aggregate size, 0.5 quantile and 0.95 quantile with named aggregations. Then add a low_sample flag. pandas uses linear interpolation between ord...