Filters
How to search
  • Plain words find names, texts and examples.
  • "two words" finds the exact phrase.
  • --name or -x finds an option.
  • #word looks only inside commands.
  • @grep finds lessons and labs that use grep.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Put ! before a word to leave it out. OR between words means one of them.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search

Reliability patternsMixed 24 series

Reliability commands: timeouts, retries, queues

A reliability cheatsheet is only useful if the commands tell you something you did not already believe. These four blocks do that: they bound a call, cap a retry, watch a queue and prove what the system does under load.

Quick reference

Four blocks: set the bound, cap the retry, watch the queue, prove the shed.

Timeouts

curl -m 2 -sS https://api.example/health
curl --connect-timeout 1 -m 3 https://api.example
psql -c 'set statement_timeout=2000' -c 'select 1'
nginx -T | grep -i proxy_read_timeout
grpcurl -max-time 2 host:443 pkg.Svc/Method

Retries

curl --retry 2 --retry-connrefused -sS $URL
curl --retry 5 --retry-max-time 10 -sS $URL
ssh -o ConnectTimeout=2 -o ConnectionAttempts=3 host
kubectl rollout status deploy/api --timeout=90s
systemctl show -p RestartUSec api.service

Queues

redis-cli LLEN queue:jobs
rabbitmqctl list_queues name messages
aws sqs get-queue-attributes --queue-url $Q --attribute-names All
kubectl get hpa -n prod
systemctl status worker@1

Verify

curl -s -o /dev/null -w '%{http_code}' $URL
curl -sI https://api.example/health | head -1
redis-cli info stats | grep rejected
psql -c 'show statement_timeout'
ss -s

In one line: A limit you cannot see is a limit you will discover. Run one of these against a copy before the incident picks it for you.

Check the bound:

curl -m 2 -sS -o /dev/null -w '%{http_code}' $URL

Explained

Timeouts first. A curl call without a limit can wait for as long as the server feels like holding the connection. Set a total limit and a separate connect limit, and do the same at the proxy and the database session. If a limit is not visible in a config file, it is a default chosen by someone else.

Retries next. Curl can retry connection failures, but only when you ask it to, and the delay matters. A retry without a cap on total time is how a two-second page becomes a thirty-second one.

Queues third. Look at depth, age and the number of messages ready, not only the number published. A queue that is growing is a queue that will eventually reject or time out.

Verification last. Run a short load test, read the status codes and the time total, and check that the rejection path actually rejects. A shed rate you have never triggered is a hypothesis.

The honest caveat: most of these commands show one host. A timeout that behaves on your laptop can behave differently behind a proxy that rewrites it.

Your turn: Which command would you run first in an incident?

More notes: Reliability patterns

Open in the notes app: search, filters, copy This note on GitHub