Interview practice question
Metrics counters slowing down hot path
Backend Engineering · Concurrency · Experienced
A shared atomic counter used for metrics is incremented on every request and shows up as a bottleneck in profiles on a many-core machine. How do you fix it?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Atomic contention across cores.
- Striped/sharded counters (LongAdder).
- Per-thread counters summed on read.
- Avoids cache line ping-pong.
- Read cost slightly higher.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.