WeCodeAcademy

Step 4: Popular and slow endpoints

Two different questions: which pages are popular (most hits) and which are slow (high response time)? Use Counter.most_common for the first, and group the times per path for the second. Averages hide outliers, so also report the median and the 95th percentile (the time that 95% of requests beat): tail latency is what unhappy users feel.

Examplepython
Open in editor »

/api/progress averages about 870 ms because of its two 1.2-second failures, far above the home page. Sorting by slowest first puts the worst offenders at the top of the report, where people will read them.

Your turn: write the code

Write average(values) that returns the mean rounded to 1 decimal, or None for an empty list. Print average([100, 200, 450]) and average([]).

Quick check

Why report a percentile as well as the average?

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.