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
- Implement a thread-safe pool of N connections with acquire, release and a timeout.hardAlso on java6 min
- Write a helper that polls a condition until it is true or a timeout expires, then tell me what yours does when the condition throws.mediumAlso on sdet4 min
- Skip the definitions. Show me encapsulation, abstraction, inheritance and polymorphism, each in about ten lines of code, and then tell me when inheritance is the wrong tool.easyAlso on java4 min
- How do you model a realistic workload for a performance test?hardAlso on percentiles4 min