The symptom and three explanations#
The example is fictional. The feed-api service behind a mobile app served 41,000 requests between 11:00 and 12:00 UTC on Monday and 82,000 in the same hour on Tuesday. Its dashboards show the request rate, the error rate and latency; the error rate rose a little and latency held. Three explanations fit:
- More users. A campaign went out on Tuesday morning, and new people opened the app.
- A retry loop. App version 5.2, released the week before, resends a request whenever it gets a particular error, with no limit.
- A crawler. Something is fetching every item URL the API exposes.
The choice matters because each needs a different response: capacity for the first, a client fix or a server-side limit for the second, a rate limit for the third.
What each explanation predicts#
| Observation | More users | Retry loop | Crawler |
|---|---|---|---|
| Total requests | double | double | double |
| Distinct clients | double | unchanged | a few more |
| Requests per client, median | unchanged | unchanged | unchanged |
| Requests per client, maximum | unchanged | far higher | far higher |
| Requests repeating an earlier request ID | the usual share | a large share | none added |
| Status of the response before a repeat | the usual retryable errors | one status, again and again | none |
| User agents | the usual mix | shifts to the looping version | a new agent |
| Distinct paths | the usual set | the usual set, one endpoint growing | many URLs, each once |
Distinct clients separate more users from the other two: real growth adds people, and the other two add requests from people or programs already counted. Repeated request IDs then separate the retry loop from the crawler. The top-clients share does not help with that second split, because a few clients send most of the traffic in both.
A request ID only marks a repeat if the client keeps the same ID across retries. The draft standard for the Idempotency-Key header defines exactly that: a unique value the client generates so the server can recognize retries of the same request. The Idempotency-Key HTTP header field A trace ID added by a load balancer does not work for this. An Application Load Balancer, for example, generates a new X-Amzn-Trace-Id root for each request that arrives without one, so each retry gets a new value. Request tracing for your Application Load Balancer
The lab: one hour of access log, four ways#
The script writes one hour of access log for a baseline and three worlds, then reads each one the way you would read a real log. Each line has a time, a client address, a user agent, a path, a status and a request ID. In every world 2% of requests get a 503 and the app retries each once with the same ID. In the users world there are twice as many clients. In the retries world ten clients on app/5.2 get a 409 on /v1/sync and resend it about once a second for the hour. In the crawler world 20 addresses with the agent ExampleBot/2.1 fetch 40,000 item URLs. It needs Python 3.8 or later.
import collections, random, statistics, sys
PATHS = ["/v1/feed", "/v1/items", "/v1/search", "/v1/sync"]
def gen(world, seed=3):
"""One hour of access log: time, client address, user agent, path, status, request id."""
rng = random.Random(seed)
users = 2000 if world == "users" else 1000
rows = []
for u in range(users):
ip, ua = f"10.{u // 250}.{u % 250}.{rng.randrange(1, 250)}", rng.choice(["app/5.1", "app/5.2"])
for _ in range(rng.randint(10, 70)):
t, path, rid = rng.uniform(0, 3600), rng.choice(PATHS), f"{rng.getrandbits(48):012x}"
status = 503 if rng.random() < 0.02 else 200
rows.append((t, ip, ua, path, status, rid))
if status == 503: # every client retries a 503 once, same id
rows.append((t + 1, ip, ua, path, 200, rid))
if world == "retries" and ua == "app/5.2" and u % 50 == 0:
rid, t = f"{rng.getrandbits(48):012x}", rng.uniform(0, 60)
while t < 3600: # a stale cursor: 409, retried forever
rows.append((t, ip, ua, "/v1/sync", 409, rid))
t += rng.uniform(0.5, 1.5)
if world == "crawler":
for n in range(40000):
rows.append((rng.uniform(0, 3600), f"203.0.113.{10 + n % 20}", "ExampleBot/2.1",
f"/v1/items/{rng.randrange(10**6)}", 404 if rng.random() < 0.1 else 200, "-"))
return sorted(rows)
def read(rows, world):
per_client = collections.Counter(r[1] for r in rows)
counts = sorted(per_client.values())
top20 = sum(c for _, c in per_client.most_common(20)) / len(rows)
last_status, repeats, before = {}, 0, collections.Counter()
for t, ip, ua, path, status, rid in rows:
if rid != "-" and rid in last_status:
repeats += 1
before[last_status[rid]] += 1
last_status[rid] = status
agents = collections.Counter(r[2] for r in rows)
paths = len(set(r[3] for r in rows))
print(f"world={world}: {len(rows)} requests from {len(per_client)} clients to {paths} distinct paths")
print(f" requests per client: median {statistics.median(counts):.0f}, max {counts[-1]}; "
f"top 20 clients send {top20:.0%}")
print(f" requests repeating an earlier request id: {repeats / len(rows):.1%}; status before the repeat: "
+ ", ".join(f"{s} {n / repeats:.0%}" for s, n in before.most_common(2)))
print(" user agents: " + ", ".join(f"{a} {n / len(rows):.0%}" for a, n in agents.most_common(3)))
if len(sys.argv) < 2 or sys.argv[1] not in ("baseline", "users", "retries", "crawler"):
sys.exit("usage: python3 doubled.py baseline|users|retries|crawler [seed]")
world = sys.argv[1]
read(gen(world, seed=int(sys.argv[2]) if len(sys.argv) > 2 else 3), world)
Save it as doubled.py. Before running it, write down which lines will differ from the baseline in each world. Then run:
for world in baseline users retries crawler; do python3 doubled.py "$world"; done
Python 3.11 printed:
world=baseline: 40841 requests from 1000 clients to 4 distinct paths
requests per client: median 41, max 73; top 20 clients send 4%
requests repeating an earlier request id: 2.0%; status before the repeat: 503 100%
user agents: app/5.1 50%, app/5.2 50%
world=users: 82309 requests from 2000 clients to 4 distinct paths
requests per client: median 41, max 74; top 20 clients send 2%
requests repeating an earlier request id: 2.0%; status before the repeat: 503 100%
user agents: app/5.1 51%, app/5.2 49%
world=retries: 76074 requests from 1000 clients to 4 distinct paths
requests per client: median 41, max 3645; top 20 clients send 48%
requests repeating an earlier request id: 48.0%; status before the repeat: 409 98%, 503 2%
user agents: app/5.2 73%, app/5.1 27%
world=crawler: 80841 requests from 1020 clients to 39181 distinct paths
requests per client: median 41, max 2000; top 20 clients send 49%
requests repeating an earlier request id: 1.0%; status before the repeat: 503 100%
user agents: ExampleBot/2.1 49%, app/5.1 25%, app/5.2 25%
All three worlds nearly doubled the requests. Only users doubled the clients, and its requests per client, repeats and agents matched the baseline. The retries and crawler worlds both had a client sending thousands of requests and 48% or 49% of traffic from the top 20 clients. Repeats split them: 48% of the retries requests repeated an earlier ID, almost all after a 409, while the crawler added no repeats, one new agent and 39,000 new paths.
The prediction fails if the users world shows a jump in maximum requests per client, or if the crawler world shows repeated IDs. Run python3 doubled.py retries 11 to try another seed; the counts change, and the pattern should not.
Read it on a real system#
Load balancer logs give clients, agents, paths and statuses. With Application Load Balancer access logs in an Athena table created as AWS documents, the first rows of the table are one query per hour. Create the table for ALB access logs
SELECT substr(time, 1, 13) AS hour,
count(*) AS requests,
count(DISTINCT client_ip) AS clients,
count(DISTINCT request_url) AS paths
FROM alb_access_logs
WHERE time >= '2026-11-23T00:00'
GROUP BY 1 ORDER BY 1;
SELECT client_ip, user_agent, count(*) AS requests, count(DISTINCT request_url) AS paths
FROM alb_access_logs
WHERE time BETWEEN '2026-11-24T11:00' AND '2026-11-24T12:00'
GROUP BY 1, 2 ORDER BY requests DESC LIMIT 20;
The request ID lives in the application's own log, since a load balancer's log records only the fields it knows. With JSON lines that carry request_id and status, this counts repeated IDs and the status that came before each repeat:
jq -r 'select(.request_id != null) | [.request_id, .status] | @tsv' app.log |
awk -F'\t' '$1 in last { repeats++; before[last[$1]]++ } { last[$1] = $2; n++ }
END { printf "%d of %d requests repeat an earlier id\n", repeats, n;
for (s in before) print " status before repeat", s, before[s] }'
The log must be in time order for "before" to mean anything. A user agent names a crawler only by its own claim. Google documents how to confirm that an address claiming to be its crawler is one, with a reverse DNS lookup followed by a forward lookup that must return the same address. Other crawler operators may publish their own host names or address lists for the same check. Verify requests from Google crawlers
host 203.0.113.17
host crawl-203-0-113-17.bot.example
Limits#
Client addresses undercount people. A carrier-grade NAT shares one public IPv4 address among many subscribers, so real growth can arrive as more requests per address. RFC 6888 Count sessions or signed-in user IDs where the application has them.
A client that generates a new request ID for each retry hides the loop from the repeat count. It still shows as a few clients sending the same path at a steady interval, each request after the same status, which the per-client query above finds.
The baseline matters. A doubled rate against the same hour last week can be a weekly pattern rather than a change, and a doubled error count can be the same failure rate under more traffic. Compare like hours, and read rates as shares of requests. The error rate rose. More failures, or less traffic? Retries do not need a faulty client either: when a dependency fails, every client's ordinary retries add requests, which is the subject of errors that persist after the dependency recovers. The general method of choosing the observation is in Choose the observation where explanations disagree.
Questions#
How do I tell retries from real traffic in an access log?
Look for the same request ID, or the same client, path and body, sent again shortly after an error response. Real traffic from new users adds clients, while retries add requests from clients already counted, usually to one endpoint and after one status.
Does a high request count from one IP address mean a bot?
Not by itself. One address can be a NAT in front of many people, a proxy, or a single client stuck in a loop. Check the user agent, the spread of paths and whether the requests repeat an ID before calling it a crawler.
Should a client retry a 409 Conflict?
A 409 means the request could not be completed because it conflicts with the current state of the resource, and HTTP expects the client to resolve the conflict before it resubmits. RFC 9110, 409 Conflict Sending the same request again unchanged, as the looping app version in this example does, only adds load. Retry on statuses that describe a temporary condition, and limit the number of attempts.