
# Requests per second

`/actuator/qps` answers how many requests per second the server took in the last window, how long they took and how many failed, for every isolate and in total. It is the JSON of the web starter's debug feature [`qps`](../spring-boot-starter-web/server/qps.md), and exists only when that feature is in the build.

## Why

The feature logs one line per window. A load test, a dashboard or a script wants the same numbers as data, and wants them at a moment of its own choosing: after each step of a test, not every ten seconds.

## Example

```yaml
# lib/resources/application.yml
spring:
  web:
    debug:
      qps:
        enabled: true      # read by the build: run build_runner after changing it
management:
  endpoints:
    web:
      exposure:
        include: health,qps
```

```console
$ curl localhost:8080/actuator/qps
```

```json
{"seconds": 10.0, "qps": 1250.4, "requests": 12504, "errors": 0,
 "active": 14, "p50Micros": 1139, "p95Micros": 5767, "p99Micros": 8650,
 "isolates": {
   "main": {"qps": 412.0, "requests": 4120, "errors": 0, "active": 5,
            "p50Micros": 1139, "p95Micros": 5767, "p99Micros": 8650},
   "isolate-1": {"qps": 420.2, "...": "..."},
   "isolate-2": {"qps": 418.2, "...": "..."}}}
```

## The two requests

| Request | Answer |
|---|---|
| `GET /actuator/qps` | The last window, as long as `spring.web.debug.qps.log-interval` (10 seconds). `{}` before the first window has passed |
| `GET /actuator/qps/now` | Ends the window now and answers it |
| `GET /actuator/qps/<anything else>` | `404` |

`/now` is for a load test that reads after each step: the answer covers exactly the time since the last look.

- **`/now` ends the window for everybody.** The next line in the log, the next `/actuator/qps` and the next `/now` of another reader cover only the time since. Two readers of `/now` cut each other's windows short.
- `/now` also logs the window, like the end of an interval.
- With `spring.web.debug.qps.log-interval: 0` no window ends by itself and nothing is logged on a timer: a `/now` covers the time since the one before, and `/actuator/qps` answers the window of the last `/now`.
- The requests to the endpoint are requests too: they are counted, and the one being answered is in `active`.

## What is answered

| Key | Meaning |
|---|---|
| `seconds` | The length of the window |
| `qps` | Requests per second, one decimal |
| `requests` | The requests answered in the window |
| `errors` | Those answered with a `5xx` status, or that ended with an error |
| `active` | The requests in flight at the end of the window |
| `p50Micros`, `p95Micros`, `p99Micros` | The latency under which half, 95 % and 99 % of the requests were answered, in microseconds; left out without requests |
| `isolates` | The same numbers for each isolate by name, the first isolate first |

The percentiles are bounds of latency buckets, not exact times: a value is at most half as much again as the real one. What is counted and what is not (the wait for the isolate, requests refused as full) is on [the feature's page](../spring-boot-starter-web/server/qps.md#what-is-counted).

## With a pool of isolates

The numbers are those of every isolate, added up in the first one. The endpoint exists in every isolate and asks the first one (through the `primaryIsolate` bean, handler `web.qps`), so the answer is the same whichever isolate takes the request.

`/now` ends the one window of the application, whichever isolate is asked.

## Exposure

The endpoint exists when the build has the feature (`spring.web.debug.qps.enabled: true` in `application.yml` or `application.properties`, without a profile). Then it is enabled by default and, like every endpoint except `health`, not exposed over HTTP until `qps` is in `management.endpoints.web.exposure.include`.

Without the feature, `/actuator/qps` is a `404` whatever is exposed: there is no `qpsEndpoint` bean, and no code that counts.

`management.endpoint.qps.access=none` turns the endpoint off and leaves the log line. Protect it like the others (see [Security](security.md)).

## In Spring (Java)

Spring Boot's counterpart is the `metrics` endpoint with Micrometer's `http.server.requests` timer. That is a metrics system; this is the last window of a debug feature.

## See also

- [Requests per second: the debug feature](../spring-boot-starter-web/server/qps.md)
- [Isolates](isolates.md)
- [Asking the first isolate](../spring-core-dart/isolates/primary-isolate.md)
- [Endpoints](endpoints.md)
- [Security](security.md)
- [Load testing](../../docs/load-testing.md)
