feat(playground): benchmark de rendimiento con flags JetStream/E2E/payload
Añade GET /api/bench (SSE) y una seccion de simulador en index.html: un publisher inunda una room con miles de mensajes a N subscribers y una grafica en vivo anima el throughput. Las dos politicas de room se exponen como flags independientes (persist=JetStream, encrypt=E2E AEAD+Ed25519) mas tamano de payload, midiendo el coste de cada capa con la libreria cliente real. El benchmark usa peers efimeros propios, sin tocar los peers nombrados del sandbox manual. Verificado: las 4 combinaciones enc x persist con fan-out exacto. Bump app v0.2.0.
This commit is contained in:
@@ -72,6 +72,40 @@ Cleartext rooms (leave the checkbox unticked) behave like plain NATS fan-out:
|
||||
fast, ephemeral, unsigned. Encrypted rooms are the Matrix-like mode: E2E
|
||||
encrypted, persisted, and per-message signed.
|
||||
|
||||
## Benchmark: throughput simulator
|
||||
|
||||
The bottom panel of the UI is a performance simulator. Press **▶ Ejecutar
|
||||
benchmark** and one publisher floods a fresh room with thousands of messages
|
||||
that N subscribers receive (fan-out); a live canvas chart animates the sent vs
|
||||
received totals while it runs.
|
||||
|
||||
The two policy axes are exposed as **independent flags**, so the benchmark
|
||||
measures the cost of each layer in isolation:
|
||||
|
||||
| JetStream | Encryption | Room policy | What it costs |
|
||||
|---|---|---|---|
|
||||
| off | off | `{Encrypt:false, Persist:false}` | plain core NATS fan-out |
|
||||
| **on** | off | `{Encrypt:false, Persist:true}` | durable JetStream (publish ack per message) |
|
||||
| off | **on** | `{Encrypt:true, Persist:false}` | AEAD + Ed25519 signature per message, core transport |
|
||||
| **on** | **on** | `{Encrypt:true, Persist:true}` | full E2E + durable history |
|
||||
|
||||
A **payload size** slider (16 B – 8 KiB) sets the message size. Encrypted or
|
||||
persistent runs are capped to 30 000 messages (each message pays per-message
|
||||
crypto and/or a JetStream ack, so they run much slower than plain NATS).
|
||||
|
||||
The benchmark uses its own ephemeral peers (fresh identities, never persisted),
|
||||
so it never touches the named peers of the manual sandbox.
|
||||
|
||||
It is driven by an SSE endpoint that streams progress samples:
|
||||
|
||||
```bash
|
||||
curl -N "http://localhost:7700/api/bench?n_msgs=20000&n_subs=3&payload=128&encrypt=0&persist=0"
|
||||
# emits: data: {"type":"start",...} data: {"type":"sample",...} data: {"type":"done",...}
|
||||
```
|
||||
|
||||
Query params: `n_msgs`, `n_subs` (1–16), `payload` (bytes), `encrypt` (0/1),
|
||||
`persist` (0/1).
|
||||
|
||||
## State / cleanup
|
||||
|
||||
All writable state lives under `playground/local_files/`:
|
||||
|
||||
Reference in New Issue
Block a user