Good software engineering begins before the first line of code. Drawing on more than a decade in the field, I share how I approach problems: research first, plan deliberately, make architecture visible, and weigh every trade-off.
The worker is running, its CPU is idle, the email provider is up and answering in 100 ms; yet for an hour not a single confirmation email has gone out. The culprit is one order from a customer with a broken address, and a sequential consumer that retries it forever. We walk through recognizing a poison message, why the offset doesn't budge, skipping it by hand with rpk group seek, and parking the message together with its reason in a dead-letter topic. The final part of the series.
Orders go through fine, but confirmation emails arrive late: first by a few minutes, then by close to an hour. The CPU is idle, the broker is idle, the database is idle. The culprit is a worker that handles messages one at a time and a topic with a single partition. We walk through reading consumer lag, calculating a consumer's capacity as concurrency ÷ latency, and processing concurrently while committing offsets without losing messages.
A few times an hour, every page on the site returns 503 for ten seconds, then recovers on its own. The API logs no errors and no instance restarts. The culprit is a readiness check written 'to be more robust': because it asks about a shared dependency, it pulls both instances out of rotation at the same moment. We walk through what belongs in readiness and what doesn't, why you have to measure at the edge, and what fail-open does for you.
The API runs as two replicas, deploys replace them one at a time, and the proxy probes each replica's /ready every 2 seconds. Even so, ~150 requests fail with 502 on every deploy. We look step by step at what the code's 'graceful' shutdown skips, how a load balancer finds out that a replica is gone, and the recipe for zero errors in a rolling deploy (announce, drain, close).
The tax provider has a ten-second failover and it's over; checkout, however, doesn't come back, and restarts change nothing. We trace step by step how retries multiplied across layers keep a dependency in permanent overload, how abandoned work eats its capacity, and the retry budget + jitter fix that breaks the loop.
Customers get four orders, four card authorizations and four confirmation emails for a single purchase, while the app tells them the payment failed. We trace why a timed-out request keeps running on the server, the Idempotency-Key header the API ignores, and the key + unique constraint + 409/Retry-After fix that collapses retries into a single order.
In the busiest hour of the week product pages won't load; there are no 5xx at the edge, the API's latency panel looks normal, and the recommendations service's dashboard is green. We follow step by step why requests that never finish don't show up in any histogram, how a few slow requests lock up a fixed number of workers, and how to replace a 30-second timeout with a 250 ms budget that really cancels the request, plus a fallback.
On Black Friday night checkout takes seconds and product pages slow down too, yet neither the API's nor the database's CPU is busy. We follow row lock waits step by step: a transaction that waits on the payment service while holding a lock, why pg_stat_statements counts lock waiting as execution time, and the fix that cuts lock time from half a second to tens of milliseconds.
A minute after every restart the API freezes: no errors, no logs, CPU idle, requests simply never get an answer. We walk step by step through the anatomy of a connection pool, a connection that leaks on an error path, the idle in transaction session in pg_stat_activity, and the timeout that turns a silent hang into a visible error.
The mobile app's new My Orders screen takes half a second; the database is relaxed, the API is idle and every query runs in under 0.1 ms. From the staircase-shaped trace in Jaeger we follow, step by step, the N+1 query pattern, why latency grows linearly with the number of queries, and how the fix brings it down to three fixed queries.
Postgres CPU is at 100%, every endpoint waits for seconds, and the API itself is idle. We trace, step by step, how an innocent purchase counter on product pages scans 1.2 million rows, how Googlebot turns that into an outage, and how to add the index to a live table without locking it.
The tax service answers in 30 ms and the API's CPU is idle, yet placing an order takes two seconds. We trace, step by step, how a new connection per request, dns.lookup and the libuv thread pool build an invisible queue.