Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Sovereign, high-performance data protection

JOSE CEK switch under load — kryoptic

SettingValue
KMS servers2
Target rate400, 800, 1200, 1600, 2500 msg/s (one message = one decrypt + one re-encrypt)
Achieved ratelocal-r400: 400 msg/s, local-r800: 800 msg/s, local-r1200: 1200 msg/s, local-r1600: 1600 msg/s, local-r2500: 2500 msg/s
Senders256
JWE algorithmRSA-OAEP + A256GCM
Plaintext256 bytes
Warmup / measurement / CEK switch10 s / 30, 60 s / +10, 20 s
HSMkryoptic
KMS version5.29.0 (OpenSSL 3.6.5 29 Sep 2026-non-FIPS)
CPUApple M3 (8 logical cores)
Commandmise run bench:jose-cek-switch

JOSE CEK switch benchmark: ckms bench, N KMS servers, one shared HSM token

Scenario

A relay service receives JWEs from a producer application and sends each to the KMS: POST /v1/crypto/decrypt (RSA-OAEP unwrap of the CEK with the HSM private key), then POST /v1/crypto/encrypt (dir + A256GCM under a target AES key). The producer keeps one AES CEK for an hour, then switches to a new one. It must wrap each CEK once: all messages of a CEK then carry the same encrypted_key. RSA-OAEP is randomized, so re-wrapping the same CEK for every message would unwrap on the HSM every time. Each KMS process caches the unwrapped CEK under sha256(key uid ‖ encrypted_key); there is no cross-node sharing, so every KMS unwraps the new CEK on its own. The cache entry expires after unwrapped_cache_max_age (default 15 min idle), and unwrapped_cache_max_ttl, when set below 60 min, forces a re-unwrap in the middle of the hour. The load generator, all KMS processes and the HSM token run on one host, so absolute latencies include CPU contention. cek_cache debug logging is enabled (one log line per cache hit and per unwrap); the HSM unwrap counts come from those lines. Latency is measured from the scheduled send time (open loop), so queueing behind a slow request is included.

Runs

Columns of the per-run tables. Latencies are per message (one decrypt + one re-encrypt), in ms, measured from the scheduled send time. all is every server together; kms1, kms2... are one server each.

ColumnMeaning
pre p50 ms / pre p99 msMedian and 99th-percentile latency in the up-to-10 s just before the CEK switch: the normal latency, used as the baseline.
first 1 s p99 ms / max ms99th percentile and maximum latency of messages scheduled in the first second after the switch.
peak msHighest latency of any message scheduled after the switch.
recovery msTime after the switch until latency stays at most 2x the pre p99 for 1 s. - when it never does, or when there is no baseline.
slow messagesNumber of messages after the switch slower than 2x the pre p99.
errorsMessages that failed: decrypt or encrypt not 2xx, or not answered before the end of the drain period.
HSM unwraps cek0 / cek1RSA-OAEP unwraps of the first and second CEK performed by that server (counted from JOSE CEK cached log lines). One per server and CEK is the ideal. cek1 is 0 when the run never reached the switch.

Run local-r400

Target 400 msg/s, 256 senders, warmup 10 s, measurement 30 s, CEK switch at +10 s; achieved 400 msg/s (0 messages unsent).

Performance gate (≥ 95 % of target rate completed, 0 errors, recovery within the window): PASS

serverpre p50 mspre p99 msfirst 1 s p99 msfirst 1 s max mspeak msrecovery msslow messageserrorsHSM unwraps cek0HSM unwraps cek1
all2.43.43.33.519.2050
kms12.73.53.43.515.702011
kms22.02.82.62.819.203011

local-r400 timeline local-r400 per-server p99

Run local-r800

Target 800 msg/s, 256 senders, warmup 10 s, measurement 30 s, CEK switch at +10 s; achieved 800 msg/s (0 messages unsent).

Performance gate (≥ 95 % of target rate completed, 0 errors, recovery within the window): PASS

serverpre p50 mspre p99 msfirst 1 s p99 msfirst 1 s max mspeak msrecovery msslow messageserrorsHSM unwraps cek0HSM unwraps cek1
all1.73.33.33.548.40400
kms11.72.82.82.843.7020011
kms21.83.33.33.548.4022011

local-r800 timeline local-r800 per-server p99

Run local-r1200

Target 1200 msg/s, 256 senders, warmup 10 s, measurement 30 s, CEK switch at +10 s; achieved 1200 msg/s (0 messages unsent).

Performance gate (≥ 95 % of target rate completed, 0 errors, recovery within the window): PASS

serverpre p50 mspre p99 msfirst 1 s p99 msfirst 1 s max mspeak msrecovery msslow messageserrorsHSM unwraps cek0HSM unwraps cek1
all1.83.63.63.762.80660
kms11.83.63.63.762.8034011
kms21.73.43.43.555.7032011

local-r1200 timeline local-r1200 per-server p99

Run local-r1600

Target 1600 msg/s, 256 senders, warmup 10 s, measurement 30 s, CEK switch at +10 s; achieved 1600 msg/s (0 messages unsent).

Performance gate (≥ 95 % of target rate completed, 0 errors, recovery within the window): PASS

serverpre p50 mspre p99 msfirst 1 s p99 msfirst 1 s max mspeak msrecovery msslow messageserrorsHSM unwraps cek0HSM unwraps cek1
all1.73.43.45.25.2000
kms11.63.43.45.25.200011
kms21.83.53.44.54.500011

local-r1600 timeline local-r1600 per-server p99

Run local-r2500

Target 2500 msg/s, 256 senders, warmup 10 s, measurement 60 s, CEK switch at +20 s; achieved 2500 msg/s (0 messages unsent).

Performance gate (≥ 95 % of target rate completed, 0 errors, recovery within the window): PASS

serverpre p50 mspre p99 msfirst 1 s p99 msfirst 1 s max mspeak msrecovery msslow messageserrorsHSM unwraps cek0HSM unwraps cek1
all1.639.261.881.4109.2700220
kms11.640.661.878.8102.706011
kms21.638.162.081.4109.270015011

local-r2500 timeline local-r2500 per-server p99

Comparison

local-r400local-r800local-r1200local-r1600local-r2500
achieved msg/s400800120016002500
gatePASSPASSPASSPASSPASS
peak message ms (all)19.248.462.85.2109.2
recovery ms (all)0000700
measurement s / switch at s30 / +1030 / +1030 / +1030 / +1060 / +20
HSM unwraps of cek0, kms111111
HSM unwraps of cek1, kms111111
HSM unwraps of cek0, kms211111
HSM unwraps of cek1, kms211111

n/a: peak is n/a when the run never reached the CEK switch (no cek1 unwrap: none); recovery is n/a there and when the run could not sustain 95 % of its target rate (latency was already growing before the switch, so "back to normal" is undefined: none). Runs may use different measurement lengths and switch times (see the table row).