Latency spike
Not climbed yetModel answer
The average hides it: most requests are still fast, and a small share (about 1 in 100 or fewer) became very slow. Something affects only some requests: some hosts, some endpoints, some customers, or a resource that runs out now and then.
Start by narrowing it down:
- What changed at that time: a deploy, a config change, a traffic jump, a dependency's incident.
- Break the p99 down by endpoint, host, region and customer. One dimension usually lights up.
- Pull a few slow traces and see where the time goes: our code, the database, a downstream call, or waiting for a connection.
Model answer
- Whether those two run a different version (a canary, a half-finished deploy) or different config.
- Garbage collection pauses or memory pressure on those hosts.
- CPU steal or a noisy neighbour on the same physical machine; disk or network trouble on that host.
- Their connection pools or thread pools being exhausted while others are fine.
- The load balancer sending them more than their share (sticky sessions, uneven weights).
Mitigate first, investigate second: take the two hosts out of rotation, or replace them, and see whether p99 recovers. Keep one aside to debug if you can.
Model answer
The bottleneck is the connection pool, not the database. Requests queue for one of a few connections, and something is holding connections too long:
- A slow external call inside a transaction: the code opens a transaction, then calls a payment or HTTP API while holding the connection.
- A connection leak: an error path never returns the connection to the pool.
- Long transactions or a long-running report query sharing the same pool.
- A pool simply too small for current traffic.
Check pool metrics (active, idle, waiting, wait time), enable leak detection (HikariCP
leakDetectionThreshold), and look inpg_stat_activityfor connections sittingidle in transaction. Move external calls outside transactions.Model answer
- An SLO for the user-facing thing (99% of requests under 300 ms) and alerts on error budget burn rate, so you are paged for real user impact, not every blip.
- Alerts on saturation, not just symptoms: pool wait time, queue depth, thread usage, event loop lag. These rise before latency does.
- Distributed tracing sampled enough to always have slow examples to look at.
- Canary deploys with automatic rollback when the canary's latency or errors are worse than the rest of the fleet.
And write the incident review with the timeline and what made it hard to find, then fix that.
