Learning center

Errors come from 3 of 20 hosts. Bad hosts, different traffic or a different version?

Move traffic off one erroring host and see whether the errors stay with the host or follow the traffic to another. Errors that stay belong to the host or to what runs on it, and a version or zone shared by exactly the erroring hosts then tells a different build from a bad machine. Errors that follow a tenant, key or session to a new host belong to the traffic, and you can usually see that before moving anything: one tenant accounts for almost all of a host's errors while sending a small share of its requests.

The symptom and three explanations#

The example is fictional. The docs-api service runs on 20 hosts behind a load balancer that routes each tenant to a host by consistent hashing, so a tenant's cached documents stay on one host. At 16:10 UTC its 5xx rate rose. Split by host, the errors were on h03, h11 and h17, at 1% to 10% of their requests, while the other 17 hosts stayed near 0.2%. Three explanations fit:

  • Bad hosts. Something on those three machines is failing: a disk, a kernel update, or a problem in their zone.
  • Different traffic. The three hosts serve tenants that send requests the code cannot handle, and the hashing keeps those tenants there.
  • A different version. A deploy reached three hosts and stopped, and the new build fails some requests.

Uneven traffic is a property of the routing. Consistent hashing sends a key to the same host each time, and removing a host moves only that host's share of keys, about 1/N of requests with N hosts. Load balancing policies: RING_HASH Sticky sessions have the same effect for a client: an Application Load Balancer forwards later requests from the same client to the same target, bypassing the routing algorithm. Sticky sessions

What each explanation predicts#

ObservationBad hostsDifferent trafficA different version
Error rate per host, as a share of its requestshigh on the threehigh on the threehigh on the three
Requests per hostnormalnormalnormal
Errors from the host's top tenantabout that tenant's share of requestsnearly all of themabout that tenant's share of requests
Version on each hostthe same everywherethe same everywheredifferent on the three
Zone, hardware and kernel on each hostshared by the three, or host errors in their logsnothing in commonnothing in common
After one host leaves the rotationits errors stop; no other host gains themanother host starts failing for the same tenantits errors stop; no other host gains them

Error rate per host, the row the alert came from, is the same in all three columns. The tenant row and the move test both separate different traffic from the other two. The version row then separates a different build from bad hosts, which behave identically in every other row.

Normalize by requests before comparing hosts. A host that serves more requests shows more errors at the same rate, and a count of errors alone can make a busy host look bad.

The lab: one ring, three causes#

The script routes 200,000 requests from 2,000 tenants to 20 hosts with a consistent-hash ring, where half the traffic comes from a few large tenants. Every request has a 0.1% chance of failing. In badhost, requests to h03, h11 and h17 also fail 6% of the time. In version, the same three hosts run v2, which fails 6% of requests. In poison, one tenant on each of those hosts sends requests that fail 90% of the time on any host. For the four hosts with the highest error rates it prints the requests, the error rate and the share of errors and requests from the host's top erroring tenant. Then it takes h03 out of the ring, routes the same requests again and prints the worst error rate among the other 17 hosts. It needs Python 3.8 or later.

import bisect, collections, hashlib, random, sys

HOSTS = [f"h{i:02d}" for i in range(20)]
SUSPECT = ["h03", "h11", "h17"]

def h(s):
    return int(hashlib.sha256(s.encode()).hexdigest()[:12], 16)

def ring(hosts):
    points = sorted((h(f"{host}#{v}"), host) for host in hosts for v in range(100))
    keys = [p for p, _ in points]
    return lambda tenant: points[bisect.bisect(keys, h(tenant)) % len(points)][1]

def poison_tenants():
    owner = ring(HOSTS)
    found = {}
    for n in range(10000):                     # one tenant owned by each suspect host
        t = f"t{n:04d}"
        found.setdefault(owner(t), t)
    return [found[host] for host in SUSPECT]

def run(world, hosts, seed=2):
    rng = random.Random(seed)
    owner, poison = ring(hosts), set(poison_tenants())
    version = {host: "v2" if world == "version" and host in SUSPECT else "v1" for host in hosts}
    reqs, errs = collections.Counter(), collections.Counter()
    by_tenant, load = collections.defaultdict(collections.Counter), collections.defaultdict(collections.Counter)
    for _ in range(200_000):
        if rng.random() < 0.5:                 # half the traffic from a few large tenants
            tenant = f"t{min(int(rng.paretovariate(1.2)), 2000):04d}"
        else:
            tenant = f"t{rng.randrange(2000):04d}"
        host = owner(tenant)
        p = 0.001
        if world == "badhost" and host in SUSPECT: p = 0.06       # a failing disk: every request at risk
        if world == "version" and version[host] == "v2": p = 0.06 # the new build fails some requests
        if world == "poison" and tenant in poison: p = 0.9        # these tenants' payloads crash the parser
        reqs[host] += 1
        load[host][tenant] += 1
        if rng.random() < p:
            errs[host] += 1
            by_tenant[host][tenant] += 1
    return reqs, errs, by_tenant, load, version

if len(sys.argv) < 2 or sys.argv[1] not in ("badhost", "poison", "version"):
    sys.exit("usage: python3 hosts.py badhost|poison|version [seed]")
world = sys.argv[1]
seed = int(sys.argv[2]) if len(sys.argv) > 2 else 2
reqs, errs, by_tenant, load, version = run(world, HOSTS, seed)
fleet = sum(errs.values()) / sum(reqs.values())
print(f"world={world}  fleet error rate {fleet:.2%}")
for host in sorted(reqs, key=lambda x: -errs[x] / reqs[x])[:4]:
    top, n = by_tenant[host].most_common(1)[0] if by_tenant[host] else ("-", 0)
    print(f"  {host} {version[host]}  requests {reqs[host]:6d}  errors {errs[host] / reqs[host]:5.2%}  "
          f"top tenant {top}: {n / max(errs[host], 1):4.0%} of errors, {load[host][top] / reqs[host]:4.0%} of requests")
reqs2, errs2, *_ = run(world, [x for x in HOSTS if x != "h03"], seed)
moved = max(reqs2, key=lambda x: errs2[x] / reqs2[x] if x not in SUSPECT else 0)
print(f"  h03 out of the ring: fleet {sum(errs2.values()) / sum(reqs2.values()):.2%}; "
      f"worst host outside the three: {moved} {errs2[moved] / reqs2[moved]:.2%}")

Save it as hosts.py. Before you run it, write down, for each world, whether one tenant will account for most of a host's errors, and where h03's errors will go when it leaves the ring. Then run:

for world in badhost poison version; do python3 hosts.py "$world"; done

Python 3.11 printed:

world=badhost  fleet error rate 0.54%
  h17 v1  requests   4771  errors 6.27%  top tenant t0246:   2% of errors,   1% of requests
  h11 v1  requests   5078  errors 6.07%  top tenant t0011:  14% of errors,  11% of requests
  h03 v1  requests   5171  errors 5.61%  top tenant t0022:   4% of errors,   4% of requests
  h05 v1  requests   5492  errors 0.22%  top tenant t0012:  17% of errors,   9% of requests
  h03 out of the ring: fleet 0.41%; worst host outside the three: h05 0.22%
world=poison  fleet error rate 0.47%
  h11 v1  requests   5078  errors 10.04%  top tenant t0011:  99% of errors,  11% of requests
  h03 v1  requests   5171  errors 3.40%  top tenant t0022:  97% of errors,   4% of requests
  h17 v1  requests   4771  errors 1.38%  top tenant t0072:  94% of errors,   1% of requests
  h05 v1  requests   5492  errors 0.22%  top tenant t0012:  17% of errors,   9% of requests
  h03 out of the ring: fleet 0.47%; worst host outside the three: h15 2.48%
world=version  fleet error rate 0.54%
  h17 v2  requests   4771  errors 6.27%  top tenant t0246:   2% of errors,   1% of requests
  h11 v2  requests   5078  errors 6.07%  top tenant t0011:  14% of errors,  11% of requests
  h03 v2  requests   5171  errors 5.61%  top tenant t0022:   4% of errors,   4% of requests
  h05 v1  requests   5492  errors 0.22%  top tenant t0012:  17% of errors,   9% of requests
  h03 out of the ring: fleet 0.41%; worst host outside the three: h05 0.22%

The same three hosts led in all three worlds, with nearly identical request counts. In poison, each host's top tenant had 94% to 99% of its errors while sending 1% to 11% of its requests; in the other worlds the top tenant's share of errors was close to its share of requests. Taking h03 out of the ring moved its poison tenant, t0022, to h15, which then failed 2.48% of its requests, and the fleet's rate stayed at 0.47%. In badhost and version no other host gained errors and the fleet's rate fell from 0.54% to 0.41%. Those two worlds print the same numbers because they draw the same random requests; only the version column tells them apart.

The prediction fails if a host's errors follow it in poison, or if another host gains errors in badhost after the move. Run python3 hosts.py poison 9 to try another seed.

Read it on a real system#

Prometheus attaches an instance label to every series it scrapes, so a server-side request metric splits by host without extra work. Jobs and instances With OpenTelemetry's http.server.request.duration exported to Prometheus, the error ratio per host is: OpenTelemetry HTTP metrics

sum by (instance) (rate(http_server_request_duration_seconds_count{http_response_status_code=~"5.."}[5m]))
  /
sum by (instance) (rate(http_server_request_duration_seconds_count[5m]))

Add the version and zone to the same view, from a build-info metric or your inventory, and compare it against the erroring hosts. The revision guide splits errors by version over the same window. Split errors by revision

The tenant row needs requests with both the host and the tenant. Application Load Balancer access logs record the target's address and the request URL, so a tenant in the path is enough. Create the table for ALB access logs

SELECT target_ip,
       regexp_extract(request_url, '/tenants/([^/]+)/', 1) AS tenant,
       count(*) AS requests,
       sum(CASE WHEN elb_status_code >= 500 THEN 1 ELSE 0 END) AS errors
FROM alb_access_logs
WHERE time >= '2026-11-24T16:00'
GROUP BY 1, 2
ORDER BY errors DESC
LIMIT 20;

The move test changes production. With an Application Load Balancer, deregistering a target stops new requests to it and lets in-flight requests finish during the deregistration delay. deregister-targets On a load balancer that hashes keys, the equivalent is removing the host from the ring, and with consistent hashing only that host's keys move, so the test disturbs little else. Record the time, then watch whether another host's error rate rises for the same tenant.

# Changes production: h03 stops receiving new requests.
aws elbv2 deregister-targets --target-group-arn TARGET_GROUP_ARN --targets Id=INSTANCE_ID

Limits#

The move test separates cleanly only when traffic stays attached to a key. With round-robin routing, every host already gets the same mix of traffic, so errors concentrated on three hosts point to the hosts or their version without a test, and a move only spreads the load.

Load can follow the move. A host that fails because it is overloaded will stop failing when traffic leaves, and the host that takes its keys may start failing for the same reason, which looks like a poison tenant. Check whether the new host's errors come from one tenant or from all of them.

A host problem can need particular traffic to show, such as a full disk that only large uploads reach. Then the errors stay with the host and still concentrate on a few tenants. Read the host's own logs for disk and kernel errors before deciding.

A few hosts with low traffic give noisy rates. A host serving a few requests a minute can show 0% or 50% from one request; widen the window, and do not average percentiles across hosts to compare them. Averaging percentiles across hosts The method behind the table is in Choose the observation where explanations disagree.

Questions#

How do I know if one host is bad or just getting different traffic?

Split the host's errors by tenant, session or key. If one of them accounts for nearly all the errors while sending a small share of the requests, the traffic is the likelier cause. Confirm by moving that traffic or taking the host out of the rotation and watching where the errors go.

Should I just replace the erroring hosts?

Replacing them fixes bad machines and a stuck deploy, but not a poison tenant: with consistent hashing its requests reach whichever host takes over its keys. Check the tenant split first, so the replacement does not hide the cause for a few minutes and then fail again.

Why do errors on a few hosts not show on the fleet dashboard?

Three hosts out of twenty at a few percent errors add less than half a percent to the fleet's rate, which can sit inside normal variation. Split the error rate by host whenever the fleet's rate moves at all.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading