Learning center

One customer reports slowness, but the dashboards look fine. Where is their time going?

A customer who sends a small share of the traffic can wait seconds while every fleet percentile stays normal. Their requests may really be slow in your service, the time may be spent outside it, on their network, proxy or browser, or they may be timing something other than one request. Read that customer's requests at your edge, from access logs filtered by their tenant ID, and compare your server time with their client time for the same request IDs.

The symptom and three explanations#

The example is fictional. harbor-tiles, one of about 400 tenants of tiles-api, opened a ticket at 15:20 UTC: "API calls take over a second, often more." The fleet p99 for the past day is 117 ms, inside the objective, and no alert fired. harbor-tiles sends about 0.4% of all requests. Three explanations fit both the ticket and the dashboard:

  • Their requests are slow in the service. Their account holds far more rows than most, or lives on a busy shard, so the service takes longer for them.
  • The time is outside the service. Their requests leave their network through a proxy or a distant region, and the extra second is spent before the request reaches you or after the response leaves.
  • They measure something else. Their "API call" is a page in their application that makes 14 calls one after another, and the number they report is the page's time.

The first explanation is a defect or a capacity problem in your service. The other two need a different conversation with the customer. Choose the observation where explanations disagree

What each explanation predicts#

ObservationSlow in the serviceTime outside the serviceA different measurement
Fleet p99normal or slightly highernormalnormal
The tenant's p99 from your access logshighnormalnormal
Their client time against your server time, same request IDsclose to each otherclient far above serverclient far above server
Your requests per client timing11many

The fleet row cannot help: a tenant with 0.4% of the traffic sits below the 1% that a p99 leaves out. Why an average of per-host p99s is not the fleet's p99 The second row separates "slow in the service" from the other two. The third and fourth rows need the customer's own numbers, which is why the first reply to the ticket should ask for request IDs and how they timed them.

The lab: one tenant in 100,000 requests#

The script draws 100,000 requests across 400 tenants with a median of about 37 ms, and gives harbor-tiles 0.4% of them. In their-data, the service takes 12 times longer for that tenant. In their-path, their network adds 900 ms that your service never sees. In their-measure, each number they report is a page that makes 14 calls in a row. It prints the fleet p99 and the tenant's p99 from the server's side, the tenant's p99 as their client timed it, and how many server requests stand behind each of their timings. It needs Python 3.8 or later.

import random, statistics, sys

if len(sys.argv) < 2 or sys.argv[1] not in ("their-data", "their-path", "their-measure"):
    sys.exit("usage: python3 tenant.py their-data|their-path|their-measure [seed]")
world = sys.argv[1]                       # their-data | their-path | their-measure
rng = random.Random(int(sys.argv[2]) if len(sys.argv) > 2 else 6)
TENANT, SHARE = "harbor-tiles", 0.004      # one tenant sends 0.4% of the requests

def p99(xs):
    return statistics.quantiles(xs, n=100, method="inclusive")[98]

server, client = {}, []                   # server-side ms per tenant; the tenant's own timings
for _ in range(100_000):
    tenant = TENANT if rng.random() < SHARE else f"t-{rng.randrange(400)}"
    ms = rng.lognormvariate(3.6, 0.5)      # about 37 ms at the median
    if tenant == TENANT and world == "their-data":
        ms *= 12                           # their account holds 12x the rows
    server.setdefault(tenant, []).append(ms)
    if tenant == TENANT:
        net = rng.uniform(20, 40) + (900 if world == "their-path" else 0)   # their network and proxy
        page = [rng.lognormvariate(3.6, 0.5) for _ in range(13)]  # other API calls on the same page
        if world == "their-measure":     # their number is a page load: 14 API calls in a row
            server[TENANT] += page
            client.append(net + ms + sum(page))
        else:
            client.append(net + ms)

fleet = [ms for xs in server.values() for ms in xs]
mine = server[TENANT]
print(f"world={world}")
print(f"  fleet p99 (server) {p99(fleet):5.0f} ms   {TENANT} p99 (server) {p99(mine):5.0f} ms "
      f"over {len(mine)} requests")
print(f"  {TENANT} p99 as their client timed it {p99(client):5.0f} ms "
      f"over {len(client)} timings")
print(f"  server requests per client timing: {len(mine) / len(client):.0f}")

Save it as tenant.py. Before running it, write down for each world whether the fleet p99 will move, whether the tenant's server-side p99 will be high, and how far their client's p99 will sit above it. Then run for w in their-data their-path their-measure; do python3 tenant.py "$w"; done. Python 3.11 printed:

world=their-data
  fleet p99 (server)   129 ms   harbor-tiles p99 (server)  1304 ms over 410 requests
  harbor-tiles p99 as their client timed it  1339 ms over 410 timings
  server requests per client timing: 1
world=their-path
  fleet p99 (server)   117 ms   harbor-tiles p99 (server)   109 ms over 410 requests
  harbor-tiles p99 as their client timed it  1033 ms over 410 timings
  server requests per client timing: 1
world=their-measure
  fleet p99 (server)   117 ms   harbor-tiles p99 (server)   116 ms over 5740 requests
  harbor-tiles p99 as their client timed it   822 ms over 410 timings
  server requests per client timing: 14

In every world the customer's own p99 was 800 ms or more, and the fleet p99 stayed under 130 ms. Only their-data raised the tenant's server-side p99, to 1,304 ms, and there their client time sat 35 ms above it. In their-path, the server served them as fast as anyone, and the gap between client and server was about 900 ms. In their-measure, the server was fast too, and each of their numbers stood for 14 server requests. Even in their-data, a tenant twelve times slower moved the fleet p99 by 12 ms, a change a dashboard reader would not notice.

The prediction fails if the tenant's server-side p99 is high in their-path or their-measure, or if the fleet p99 rises past the objective in their-data. Run python3 tenant.py their-data 9 for other draws, and raise SHARE to find the share at which the fleet p99 starts to show one tenant's slowness.

Read it on a real system#

Per-tenant latency comes from logs or traces, not from metric labels: Prometheus advises against labels with high cardinality such as user IDs, and a label per tenant multiplies every series by the tenant count. Metric and label naming If the service writes JSON access logs with a tenant field and a duration to CloudWatch Logs, Logs Insights computes the tenant's percentiles over time with pct(); this query only reads. Logs Insights stats

filter tenant = "harbor-tiles"
| stats count(*) as requests, pct(duration_ms, 50) as p50, pct(duration_ms, 99) as p99 by bin(15m)

Run it again without the filter for the fleet, and once grouped by route for the tenant: a slow tenant is often slow on one route that touches their large data.

An application log starts its clock when your code sees the request. An Application Load Balancer's access log splits the time it saw: request_processing_time from receiving the request to sending it to a target, target_processing_time from then until the target started its response headers, and response_processing_time after that. The client:port field holds the address of whatever connected to the load balancer, which is the customer's proxy if they use one, and trace_id carries the X-Amzn-Trace-Id header for matching their request IDs. ALB access log entries None of these fields include the time between the customer's client and the load balancer; on Google Cloud, the external Application Load Balancer's total_latencies likewise excludes the client's round trip, which it reports separately as frontend_tcp_rtt. Cloud Load Balancing metrics

Ask the customer for request IDs and UTC times of slow calls, and what exactly they timed: one call, a page or a job. Link the browser evidence to the server's logs A Server-Timing response header, such as Server-Timing: app;dur=37, lets their browser's developer tools and scripts show your server time beside their own measurement of the same response. Server Timing

Limits#

A small tenant gives a short sample. Over 15 minutes, harbor-tiles may send a few dozen requests, and a p99 over a few dozen is close to the maximum. Use a longer window, or count their requests above a threshold, before comparing their percentile with the fleet's.

Server time starts later than the customer's clock. Time a request spends in an accept queue or a worker pool before your handler starts its timer is missing from the application log, though the load balancer's target time includes it. Compare the two before calling the server fast. Is the dependency slow, or the client?

"Outside the service" can still be yours. A CDN, a regional endpoint or a TLS setting you control sits on their path, so a large gap between client and server time leads to the parts of the path between them, not straight back to the customer.

Questions#

How can one customer be slow if the p99 is fine?

The p99 describes the slowest 1% of all requests. A customer who sends less than 1% of the traffic can have every request slow and still sit inside that 1%, so the fleet percentile does not move. In the lab, a tenant with 0.4% of the traffic and a 1.3-second p99 moved the fleet p99 from 117 to 129 ms.

What should I ask the customer for first?

Request IDs or trace IDs of slow calls, their UTC times, what they measured, and where they called from. With the IDs, your logs give the server time for exactly those requests, and the gap to their number shows which explanation to follow.

Should every metric carry a tenant label?

Usually not. Tenant IDs are a high-cardinality dimension, and a label for each multiplies the stored series. Keep tenant IDs in access logs and trace attributes, where per-tenant questions can be asked when a ticket arrives.

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