Skip to content

Otoroshi 18 · Part 2 of 5

Otoroshi 18: +39% throughput, half the memory per request

What we measured on the gateway's hot path, how we measured it, and how to check it on your own traffic.

4 min read Lire en français
Otoroshi 18 with better performances

On a typical route, with seven plugins including an API key check, Otoroshi 18 handles 39% more requests per second than the version before our performance pass. Each request allocates 57% less memory and uses 29% less CPU. Here is what we changed, how we measured it, and why the number that really matters comes from production.

A gateway benchmark in absolute terms means little

Gateway vendors are quick to publish figures in the tens of thousands of requests per second. Those figures depend mostly on payload size, TLS, the plugins enabled and backend latency. Several vendors say so themselves, in the fine print: their lab results do not represent a production load.

So we did something different: compare one version of Otoroshi with another, on the same bench, in exactly the same way. Only the binary changes from one measurement to the next.

What we changed

Once the port to Scala 3 and Pekko was done, we audited the path every request follows, from the moment it enters the gateway to the backend call. We looked for anything doing unnecessary work on every request. A few examples:

  • The execution report of each request is only built if someone reads it.
  • Metrics are aggregated in memory per route and written once per second, instead of one message sent per request.
  • Timeouts cancel their timer as soon as the call completes.
  • The path, host and client address are resolved once when the request arrives, then shared by all plugins.
  • The expression language does no work at all on a string that contains no expression.
  • Id generation no longer goes through a lock shared between threads.
  • JSONPath evaluation is significantly faster, which benefits every plugin that uses it.
  • JWKS public keys and the validation verdict of a JWT are cached.
  • Response timers run on the side: the response no longer waits for them.

None of these changes is spectacular on its own. Put together, they change the cost of every request.

How we measured

The bench is deliberately simple and reproducible:

  • same JVM (Temurin 21, 2 GB heap, G1), same options, in-memory storage;
  • same Node.js backend, same load generator (wrk, 4 threads, 64 connections);
  • two routes: a minimal one (a single host rewrite) and a typical one (API key, X-Forwarded-* headers, headers added with an expression, CORS, Otoroshi headers);
  • three rounds, alternating the order of the versions, each version on a fresh JVM, with a warm-up then two 15-second measurements per route.

We compared 18.0.0-preview8, before the performance pass, with preview9, which contains all of this work.

The results

Median values over six measurements per version.

Typical route Before After Change
Requests per second 11,704 16,290 +39%
Median latency 4.84 ms 3.48 ms −28%
Memory allocated per request 545 KB 235 KB −57%
CPU per request 714 µs 509 µs −29%
Minimal route Before After Change
Requests per second 17,911 23,779 +33%
Median latency 2.53 ms 2.07 ms −18%
Memory allocated per request 246 KB 122 KB −51%
CPU per request 446 µs 329 µs −26%

No error responses and no socket errors across all measurements.

The drop in memory allocation is the most important number. Less allocation means less work for the garbage collector, so less CPU and less frequent pauses as load rises.

One honest caveat: the load generator, the backend and Otoroshi share the same machine. These numbers are for comparing two versions with each other, not for claiming an absolute throughput.

And compared with 17?

We also ran 17.17.0 and 18.0.1 on the same bench. On memory allocation, the gap is even wider: each request on the typical route allocates 682 KB in 17 and 267 KB in 18, 61% less. On the minimal route, it goes from 365 KB to 139 KB, 62% less. For each route, all six measurements of 18 are below all six measurements of 17.

A JVM that sizes itself

A fast gateway that is badly sized is still a slow gateway. The Otoroshi 18 Docker image now sizes the JVM from the container limits: 60% of the memory for the heap, while keeping 512 MB outside of it, G1, and a clean exit when memory runs out rather than a process slowly dying. The Helm chart and the Kustomize manifests no longer hard-code JAVA_OPTS, they declare their requests and limits, and autoscaling is based on CPU.

The number that matters: yours

The best benchmark is still your own traffic. Otoroshi measures its own overhead and records it in every gateway event, separately from the time spent in the backend. So you can follow the effect of an upgrade, route by route, on your real traffic.

Nothing to change on your side

These gains require no tuning: not one plugin to modify, not one route to rewrite. Just upgrade to 18. On Otoroshi Managed, it is already done: the clusters run 18.

Want to understand where your requests spend their time on your own installation? The Cloud APIM team, who wrote this code, can help: support and consulting.

Further reading

Next post: what changes for you in Otoroshi 18, from API consumers to security.

Type to search every post.

↑ ↓ to navigate↵ to openesc to closePowered by Pagefind