Skip to content
English

Time behaviour

The first chapter opened with a person who opens a project and asks for its information. Suppose their client receives the complete response 400 ms after sending the request, and the person sees a usable result 480 ms after acting. Both numbers describe the same query. Which one does G01’s 500 ms criterion use?

This chapter is about Time behaviour: how long responses and work take under stated conditions. It uses the same hypothetical G01 scenario as chapter one. None of the services, figures or results describe TDP. The criteria are illustrative and unapproved, and every observation is synthetic. Where this chapter adds numbers that G01 does not contain, such as queue time, first byte or a monitoring window, it says so.

The 400 ms and 480 ms above belong to one hypothetical request. G01’s criterion applies to a population of successful responses, which the second section covers.

The user waits longer than the request

G01 measures response time from the moment the client dispatches the request until it receives the complete response. The person’s wait starts earlier and ends later.

Hypothetical G01 project query. The response interval is part of the complete user wait. G01 timing example.

Text equivalent. In the hypothetical G01 journey, the user acts at t0. The client prepares and dispatches the request at t1, receives the complete response at t6 and presents the usable result at t7. Dispatch to receipt takes 400 ms. Action to usable result takes 480 ms, including the 400 ms response interval. Arrows show events in order. The summary identifies the measured intervals and their endpoints.

The answer to the opening question is the 400 ms interval, from t1 to t6. The 80 ms outside it is client work: preparing the request before dispatch and presenting the result after receipt. A requirement about what the person experiences needs the t0 to t7 interval, recorded on the client with a defined start event and a defined usable-result event. That interval is an observable stand-in for perceived wait. It records when the result appeared, not how long the wait felt.

Browser APIs do not supply t7 for you. W3C Event Timing measures an interaction up to the next rendering update, and that paint need not contain the result the person was waiting for.

Service latency, dependency latency and time in queue

Inside the response interval sit narrower ones. G01’s journey gives 300 ms from the moment the service accepts the request until it sends the response, and 180 ms for a call to a data dependency. This example adds a work queue to the same query. The query joins the queue when the service accepts it and starts processing 60 ms later.

Service and dependency durations come from G01. The queue and intermediate timestamps are synthetic additions. G01 timing example.

Text equivalent. On the synthetic service clock, acceptance and enqueueing occur at 0 ms, processing begins at 60 ms, the dependency runs from 80 to 260 ms, and the service sends at 300 ms. Queue wait is 60 ms, dependency latency is 180 ms and service latency is 300 ms. The two shorter durations are already included in the 300 ms service span. The queue boundaries and intermediate timestamps are illustrative additions to the G01 timing example.

Each span starts at its own event. Adding 60, 180 and 300 ms would count the same time twice, and none of them is the 400 ms response time. A short service span tells you the service was quick. It does not tell you the person got a quick result.

In a real trace, the spans may come from different machines. Measure each one as an elapsed duration on a single monotonic clock, then link the spans through the request ID. Subtracting a timestamp taken on one machine from a timestamp taken on another mixes in the error between their clocks.

Time to first byte

The client can also see when the response starts to arrive. In this synthetic lookup, measured from dispatch on an already established connection with no interim HTTP response, the first response byte arrives at 340 ms and the complete response at 400 ms.

Synthetic G01 extension on an established connection with no interim HTTP response. Spacing shows event order. G01 timing example.

Text equivalent. From client dispatch at 0 ms, the first response byte takes 340 ms and complete receipt takes 400 ms. The first-byte event and receipt of the complete response are 60 ms apart. This first-byte value is a synthetic addition to G01 and uses the client clock. The diagram gives event order and labeled intervals.

Within this boundary, time to first byte (TTFB) is 340 ms. G01’s response time still runs to the last byte, 60 ms later. Tools disagree about where TTFB starts, so name the start event before comparing two numbers. A navigation TTFB measured from the start of a page navigation can include redirects and connection setup, as the Chrome team’s TTFB guidance explains. W3C Resource Timing exposes the separate timestamps a browser records for each resource. If the server sends an interim response before the final one, state whether your metric ends at the interim response’s first byte or at the start of the final response.

What counts as a fast, successful query?

Each measure answers a different question about the same workload. G01’s criteria combine several of them.

Measure Question it answers Population
Response time How long do successful requests take from dispatch to complete receipt? Successful responses
Complete user wait When does the result become usable, including preparation and presentation? Successful journeys observed on the client
Successful throughput How many correct, authorized results complete per second? Successes in a stated window
Error fraction What share of eligible arrived requests fail? All eligible arrivals

An eligible request is a G01 project read from a requester who is authorized to see that project. In G01’s synthetic workload, every arrival is eligible. A success means the correct information for that request. An HTTP 200 carrying the wrong project, or another user’s data, is an error. So are rejected requests and requests with no outcome within G01’s 5 s timeout. When you apply the same measure to live traffic, decide first how to count requests without permission. A correct access denial is the expected response to such a request, so it is not an error of the read. Count those denials separately and keep them out of the eligible population. Throughput counts useful work, which is why offered requests, concurrent users and 2xx responses cannot stand in for it. When you monitor a live system, a journey for which the client sent no timing data is a missing timing observation. Report those journeys separately as a gap in coverage. If the server or another source records the outcome, that outcome still counts as a success or an error; only its timing is unknown.

G01 also requires that at least 95% of successful responses arrive within 500 ms. The 400 ms response from the opening is one request and cannot show whether that holds. You need the distribution.

Example: finding p95 in Run A. In G01’s synthetic Run A, 29,850 requests succeed and 150 fail, out of 30,000 arrivals. Sort the successful response times. The 95th percentile (p95) is the value at rank 0.95 × 29,850 = 28,357.5, rounded up to 28,358, counting from one. The fastest 27,000 successes take 300 ms and the next 1,400 take 420 ms, so ranks 27,001 to 28,400 hold 420 ms. Rank 28,358 falls among them: p95 is 420 ms.

The acceptance check needs no percentile at all. Count the successes at or below 500 ms: 29,400 of 29,850, which is 98.49%. That is at least 95%, so the timing criterion passes. The 150 errors are not part of this population. They stay in the error fraction, 150 out of 30,000 arrivals, or 0.50%. Dropping them from both reports would hide them.

Synthetic G01 Run A. The 5% limit marks the largest pending share compatible with 95% of successes already complete. G01 Run A distribution.

Text equivalent. The bars show the share of the 29,850 eventual successes that finish after each cutoff in synthetic Run A. At 300 ms, 2,850 are still pending (9.55%). At 420 ms, 1,450 are pending (4.86%). This is the first cutoff at or below the 5% limit, so p95 is 420 ms. At 500 ms, 450 are pending (1.51%), and 29,400 have finished (98.49%), meeting the timing criterion. By 900 ms, all 29,850 are complete. The chart rounds the shares and the rank calculation uses the exact counts from the full Run A distribution.

A p95 is a cutoff for a population, not a promise to each person. In Run A, 450 successful responses still take 900 ms.

The same measures in a benchmark and in production monitoring

A controlled run and a monitoring window can report the same measures. They support different conclusions.

The controlled run is G01’s synthetic Run A. It uses 100,000 synthetic project records, up to 100 concurrent simulated users and a service cache that starts empty. Arrivals ramp from zero to 50 requests/s over one minute and then hold at 50 requests/s for 600 s. The measures cover the hold, which includes the cache warming up. Record the arrivals the load generator actually produced. A generator that falls behind its schedule has not tested the intended load, however short the times it reports. Grafana k6 describes how open and closed load models treat that differently.

The monitoring window is invented for this chapter. It is not production data. Eligible traffic arrives at 40 requests/s for 300 s and then at 60 requests/s for 300 s: the same 30,000 arrivals as Run A with a different load profile. G01 holds 50 requests/s for the whole 600 s, so this window does not reproduce G01’s conditions. Both columns use the same query, the same definition of success and error, the same 5 s timeout and the same timing boundaries. To keep the arithmetic readable, both examples assume complete instrumentation, no retries, no missing user journeys and no work that crosses the edges of the window.

Measure Synthetic G01 Run A Illustrative monitoring window
Arrivals in 600 s 50/s × 600 s = 30,000 40/s × 300 s + 60/s × 300 s = 30,000
Correct authorized successes and errors 29,850 + 150 = 30,000 29,700 + 300 = 30,000
Successful throughput (both window definitions below) 29,850 / 600 s = 49.75/s 29,700 / 600 s = 49.50/s
Error fraction 150 / 30,000 = 0.50% 300 / 30,000 = 1.00%
Successful responses within 500 ms 29,400 / 29,850 = 98.49% 28,200 / 29,700 = 94.95%
Successful response p95 420 ms 700 ms
Action-to-usable-result p95 among successes 500 ms, synthetic extension to Run A 800 ms, synthetic monitoring data

To check either p95, multiply the success count by 0.95, round up to a whole number and read that position from the sorted response times, counting from one.

Example Response-time buckets Rank and p95
Run A 27,000 at 300 ms, 1,400 at 420 ms, 1,000 at 500 ms, 450 at 900 ms Rank 28,358 gives 420 ms
Monitoring 28,200 at 450 ms, 1,000 at 700 ms, 500 at 900 ms Rank 28,215 gives 700 ms

In the monitoring window, 0.95 × 29,700 is exactly 28,215. The first 28,200 successes take 450 ms, so rank 28,215 is in the 700 ms bucket.

The user-wait row needs client preparation and presentation time, which G01 does not specify. As a teaching assumption, add 80 ms to every Run A response time and 100 ms to every monitoring response time. Run A’s buckets become 380, 500, 580 and 980 ms, and rank 28,358 gives a user-wait p95 of 500 ms. The monitoring buckets become 550, 800 and 1,000 ms, and rank 28,215 gives 800 ms. These additions only illustrate the t0 to t7 boundary. G01’s 500 ms criterion still applies to response time.

Do not average percentiles from shorter intervals to get the p95 for the whole window. The average of ten one-minute p95 values is not the window’s p95. Compute it from the individual observations, or from a distribution summary whose approximation error you state.

What each setting supports

Run A passes every illustrative G01 criterion for the configuration it tested. Timing passes at 98.49%, throughput at 49.75 successes/s and errors at 0.50%. The guide’s worked results also record a highest one-minute CPU average of 65% of two allocated cores and peak service memory of 1.2 GiB, within the resource limits. That result holds for those conditions. It does not predict behaviour under other data, traffic or configuration.

Applied to the monitoring window, the same thresholds give mixed results. Successful throughput, 49.50/s, meets the minimum of 49 successes/s. The timing share misses its threshold, because 94.95% is below 95%. The error fraction also misses, because 1.00% is not strictly below 1%. Those two misses flag a problem under the demand that arrived in that window. They are not a G01 result: the window alternated between 40 and 60 requests/s instead of holding 50, and matched G01 only in its total arrivals. What would happen under G01’s load needs a run under G01’s conditions. As a separate limit, the example supplies no resource observations, so CPU and memory remain unevaluated.

The monitoring window in this chapter is invented, so it shows only the kind of reading a real window allows. A real monitoring window can show who was affected under the demand that actually arrived, within the coverage of the instrumentation. It has to report how much telemetry is missing and whether the observed traffic is a biased sample. It cannot say why the tail grew. To support a cause, you need further evidence, such as a controlled comparison that changes one suspected factor and keeps the other conditions comparable. The Google SRE workbook separates measured indicators from the targets set for them, and warns that a measurement may not capture everything users experience.

Example: why the window matters. Cohort-normalized throughput divides the eventual successes from the requests that arrived in a 600 s window by 600 s. Completion throughput divides the successes that finish during a 600 s wall-clock window by 600 s, and can include requests that arrived earlier. The two rates give the same value in each column of the table because no work crosses the window edges in either example. In practice, follow the arrival cohort until each outcome is known or its timeout expires before you compute its timing and error measures. Report the work still in flight and the outcomes that arrived late.

A shorter window shows how the two rates diverge. Take a synthetic 10 s window. Three requests arrive inside it: one succeeds inside the window, one succeeds after it and one fails. Two requests that arrived before the window also succeed inside it. Count each request once, by the event that the rate uses.

Synthetic 10-second window. Horizontal placement shows which side of the window a timed event falls on. Worked window example.

Text equivalent. Two eventual successes among three in-window arrivals give 0.20 successes/s when divided by 10 s. The single failure gives an arrivals-based error fraction of 1/3, or 33.3%. Three successes finish during the window, including two from before it, so completion throughput is 0.30 successes/s. The example is synthetic.

Neither rate is wrong. They answer different questions. What you must not do is divide a count of completions by an unrelated arrival population and call the result an error fraction.

An acknowledgement can arrive while the work is still running

Some operations answer before the work is done. Take a hypothetical project export, separate from G01’s read. The user submits the job and the service replies with HTTP 202 Accepted. The export becomes available later, and the client fetches it after checking its status. Under RFC 9110 §15.3.3, 202 means the request was accepted for processing but the processing has not been completed. The request might or might not eventually be acted upon, and it might be disallowed when processing actually takes place. HTTP has no way to send a final status later on that same response.

Hypothetical export. The milestones share a submission origin in the simulated chronology. Spacing shows event order. RFC 9110 §15.3.3.

Text equivalent. In the synthetic export journey, the client receives the acknowledgement 80 ms after submission. The result becomes available at 12 s. The client presents a usable result at 13 s after checking and downloading it. Each value is elapsed time from submission. Another job can fail after acceptance or still be pending when observation ends.

Three times start at the same submission: 80 ms to the acknowledgement, 12 s to availability and 13 s to a usable result. The last second belongs to the user’s journey even though the export already exists. A fast acknowledgement tells the person their request was received. It says nothing about how long they will wait for the export, or whether they will get one.

The 80 ms and 13 s both start and end on the client, so one client clock can measure them. The 12 s comes from the simulated timeline: it starts with the client’s submission and ends with an event on the service. In a real system, subtracting those two timestamps would mix in the clock error described earlier. Measure availability on the service’s own clock, from the moment it accepted the job, and record separately when the client first observed that the export was ready.

Example: reconciling a job cohort. A synthetic cohort of 1,000 export jobs is submitted during a 600 s window. Observation stops when that window closes. By then, 990 submissions have been acknowledged and 10 rejected. Of the 990 acknowledged jobs, 940 have succeeded by the cutoff, 30 have failed and 20 are still pending: 940 + 30 + 20 = 990. The acknowledgement rate is 990 out of 1,000. That counts accepted jobs, not completed ones.

Keep separate counters for acknowledgements and for final outcomes, and decide in advance how a retried submission maps back to a single job. The distribution of time to a usable result needs a client event for each job: the moment the export was presented. An export can be available on the service and still not downloaded when observation stops. For this example, assume the clients presented all 940 successful exports before the cutoff and each presentation was correlated with its job, so those 940 presentations are the population. In a real system, report available results and observed presentations as separate counts. The single job’s 13 s only illustrates the boundary.

Throughput needs the same care as before. At the cutoff, the cohort has 940 known successes and 20 jobs without an outcome. Its cohort-normalized throughput, based on eventual successes, is not final yet. It will fall between 940 / 600 s = 1.57 jobs/s and 960 / 600 s = 1.60 jobs/s, depending on how the pending jobs end. Follow them to an outcome or to the defined timeout before reporting it. A 600 s wall-clock completion window is a different measure. It counts every job that finishes successfully during the window, including jobs submitted earlier. If such a window records 940 successful completions, its completion throughput is 940 / 600 s = 1.57 jobs/s. Two rates with the same count over the same duration have the same value even when they count different jobs, so matching numbers do not show that the same work was counted.

Write a timing scenario you can test

Pick one operation from your own work, a query or a job, and write down:

  • the start event and the usable-result event, and which clock records each;
  • which requests are eligible, what counts as a correct outcome, and which failures count as errors;
  • the load, data and configuration under which the measure applies;
  • the observation window, and how you will treat failures, timeouts, retries and work still pending when the window closes;
  • the evidence you would collect in a controlled test, and what you would monitor in production.

If two people on your team would place the start or end event differently, the scenario is not ready yet. The scenario template adds the criteria, the target owner and the approval status a team needs before treating any of these numbers as a target.

Sources