Skip to content
Preptima
mediumCodingMidSenior

Given an access log, write a utility that reports request count, error rate and p95 latency per endpoint.

5 min readUpdated 2026-08-15

Answer

Short answer

Group lines by a normalised path so that /orders/1 and /orders/2 collapse to one endpoint, compute the percentile by nearest rank on the sorted latencies, and count the lines you could not parse instead of silently dropping them.

Was this answer helpful?

Likely follow-ups

  • The log is 40 GB. What changes in your implementation?
  • How would you compute p95 without holding every latency in memory?
  • Two of your endpoints are the same resource with different casing. Whose problem is that?
  • How would you test the percentile calculation without duplicating the implementation in the test?

Related questions

Related Topics