# h2load — HTTP/2-Lasttest auf der Kommandozeile

> Praxis-Guide zu h2load — HTTP/2- und HTTP/1.1-Lasttests mit parallelen Streams, TLS, Ratensteuerung und experimentellem HTTP/3 (QUIC).

Source: https://www.jpkc.com/db/cheatsheets/networking/h2load/

<!-- PROSE:intro -->
h2load ist das Benchmarking- und Lasttest-Werkzeug aus dem nghttp2-Projekt: Damit misst du den Durchsatz und die Latenz deines Servers unter HTTP/2- und HTTP/1.1-Last – mit echten parallelen Streams, wie sie ein Browser sendet. Mit wenigen Parametern schickst du hunderttausend Requests von hundert gleichzeitigen Clients los, steuerst die Verbindungsrate, verwendest TLS oder Klartext, und liest die Ergebnisse direkt aus der kompakten Ausgabe ab.
<!-- PROSE:intro:end -->

## Grundlegende Nutzung

`h2load <url>` — Sendet eine einzelne Anfrage an die angegebene URL (Standard: 1 Request, 1 Client).

```bash
h2load https://localhost:8443/
```

`h2load -n <requests> -c <clients> -m <streams> <url>` — Führt einen Benchmark mit N Gesamtrequests, C gleichzeitigen Clients und M maximalen parallelen Streams pro Session durch.

```bash
h2load -n100000 -c100 -m10 https://localhost:8443/
```

`h2load -n <requests> -c <clients> -t <threads> <url>` — Nutzt mehrere native Threads. Hilfreich, wenn der Benchmark-Client selbst zum Flaschenhals wird.

```bash
h2load -n100000 -c100 -t4 https://localhost:8443/
```

`h2load -n <requests> -c <clients> -m <streams> -t <threads> <url>` — Vollständiger Benchmark mit Threads, Clients und parallelen Streams.

```bash
h2load -n1000000 -c200 -m50 -t8 https://localhost:8443/
```

## Zeitbasiertes Benchmarking

`h2load -c <clients> -m <streams> -D <duration> <url>` — Läuft für eine feste Dauer statt einer festen Anzahl von Requests. Die Option `-n` wird ignoriert.

```bash
h2load -c100 -m10 -D 30s https://localhost:8443/
```

`h2load -c <clients> -m <streams> -D <duration> --warm-up-time=<duration> <url>` — Führt einen Test mit Aufwärmphase durch, bevor die eigentliche Messung beginnt. Erfordert `-D`.

```bash
h2load -c100 -m100 -D 60s --warm-up-time=5s https://localhost:8443/
```

## Ratensteuerung

`h2load -n <requests> -c <clients> -r <rate> <url>` — Baut Verbindungen mit einer festen Rate pro Sekunde auf. Gleichmäßig auf Threads verteilt. Schließt `-D` aus.

```bash
h2load -n10000 -c100 -r4 -t2 https://localhost:8443/
```

`h2load -n <requests> -c <clients> -r <rate> --rate-period=<duration> <url>` — Baut Verbindungen mit einer festen Rate pro benutzerdefiniertem Zeitraum auf.

```bash
h2load -n10000 -c100 -r10 --rate-period=500ms https://localhost:8443/
```

`h2load -n <requests> -c <clients> --rps=<N> <url>` — Begrenzt Requests pro Sekunde für jeden Client. Schließt `--timing-script-file` aus.

```bash
h2load -n10000 -c10 --rps=100 https://localhost:8443/
```

## Protokollauswahl

`h2load --h1 <url>` — Erzwingt HTTP/1.1 für TLS- und Klartext-Verbindungen.

```bash
h2load -n1000 -c10 --h1 https://localhost:8443/
```

`h2load -p h2c <url>` — Verwendet HTTP/2 im Klartext (h2c) für Verbindungen ohne TLS. Das ist der Standard.

```bash
h2load -n1000 -c10 -p h2c http://localhost:8080/
```

`h2load -p http/1.1 <url>` — Verwendet HTTP/1.1 für Klartext-Verbindungen.

```bash
h2load -n1000 -c10 -p http/1.1 http://localhost:8080/
```

`h2load --alpn-list=<protocols> <url>` — Legt die ALPN-Protokollliste für die TLS-Aushandlung in bevorzugter Reihenfolge fest.

```bash
h2load -n1000 -c10 --alpn-list=h2,http/1.1 https://localhost:8443/
```

`h2load --alpn-list=h3 <url>` — Verwendet HTTP/3 (QUIC). Experimentell, erfordert h2load mit QUIC-Unterstützung.

```bash
h2load -n1000 -c10 --alpn-list=h3 https://localhost:443/
```

## Header und POST-Daten

`h2load -H '<header>' <url>` — Fügt einen HTTP-Header hinzu oder überschreibt ihn. Kann mehrfach angegeben werden.

```bash
h2load -n1000 -c10 -H 'Authorization: Bearer token123' https://localhost:8443/api
```

`h2load -H '<h1>' -H '<h2>' <url>` — Fügt mehrere eigene Header hinzu.

```bash
h2load -n1000 -c10 -H 'Accept: application/json' -H 'X-API-Key: abc123' https://localhost:8443/api
```

`h2load -d <path> <url>` — Sendet den Dateiinhalt als POST-Body an den Server. Ändert die Anfragemethode auf POST.

```bash
h2load -n1000 -c10 -d /tmp/payload.json -H 'Content-Type: application/json' https://localhost:8443/api
```

## URI-Eingabe und Skripte

`h2load <url1> <url2> <url3>` — Benchmarkt mehrere URIs im Rundlauf-Verfahren. Nur Schema, Host und Port der ersten URI werden genutzt.

```bash
h2load -n10000 -c50 https://localhost:8443/ https://localhost:8443/api https://localhost:8443/health
```

`h2load -i <file> <url>` — Liest URIs aus einer Datei (eine pro Zeile). Verwende `-` für stdin. Deaktiviert Kommandozeilen-URIs.

```bash
h2load -n10000 -c50 -i urls.txt https://localhost:8443/
```

`h2load --timing-script-file=<file>` — Spielt zeitgesteuerte Request-Skripte ab. Jede Zeile: Millisekunden-Offset<TAB>URI. Mit `-n` werden Requests pro Client gezählt.

```bash
h2load -c10 --timing-script-file=script.txt
```

`h2load -B <base_uri> -i <file>` — Überschreibt Schema, Host und Port für alle URIs aus der Eingabedatei.

```bash
h2load -n10000 -c50 -B https://staging.example.com -i urls.txt
```

`h2load -B unix:<path> <url>` — Verbindet über einen UNIX-Domain-Socket.

```bash
h2load -n1000 -c10 -B unix:/tmp/nghttpx.sock http://localhost/
```

## Verbindung und Timeouts

`h2load -T <duration> <url>` — Setzt das maximale Timeout für aktive Verbindungen, unabhängig von der Aktivität.

```bash
h2load -n1000 -c10 -T 30s https://localhost:8443/
```

`h2load -N <duration> <url>` — Setzt das maximale Inaktivitäts-Timeout für Verbindungen.

```bash
h2load -n1000 -c10 -N 10s https://localhost:8443/
```

`h2load --connect-to=<host>:<port> <url>` — Verbindet zu einem anderen Host:Port als in der URI angegeben.

```bash
h2load -n1000 --connect-to=127.0.0.1:8443 https://example.com/
```

## HTTP/2-Flusskontrolle

`h2load -w <bits> -W <bits> <url>` — Setzt die initiale Fenstergröße auf Stream-Ebene (`-w`) und Verbindungsebene (`-W`) als (2^N)−1 Bytes. Standard: 30 (sehr groß).

```bash
h2load -n100000 -c100 -m10 -w16 -W16 https://localhost:8443/
```

`h2load -f <size> <url>` — Setzt die maximale HTTP/2-Frame-Größe, die der lokale Endpunkt empfangen möchte.

```bash
h2load -n10000 -c50 -f 32K https://localhost:8443/
```

`h2load --header-table-size=<size> <url>` — Setzt die HPACK-Decoder-Header-Tabellengröße.

```bash
h2load -n10000 -c50 --header-table-size=8K https://localhost:8443/
```

`h2load --encoder-header-table-size=<size> <url>` — Setzt die HPACK-Encoder-Header-Tabellengröße.

```bash
h2load -n10000 -c50 --encoder-header-table-size=8K https://localhost:8443/
```

## TLS-Konfiguration

`h2load --ciphers=<suite> <url>` — Legt die erlaubten Cipher-Suites für TLSv1.2 oder früher fest (OpenSSL-Format).

```bash
h2load -n1000 -c10 --ciphers=ECDHE-RSA-AES128-GCM-SHA256 https://localhost:8443/
```

`h2load --tls13-ciphers=<suite> <url>` — Legt die erlaubten Cipher-Suites für TLSv1.3 fest (OpenSSL-Format).

```bash
h2load -n1000 -c10 --tls13-ciphers=TLS_AES_256_GCM_SHA384 https://localhost:8443/
```

`h2load --groups=<groups> <url>` — Legt unterstützte TLS-Gruppen (Schlüsselaustausch) fest.

```bash
h2load -n1000 -c10 --groups=X25519:P-256 https://localhost:8443/
```

`h2load --sni=<dnsname> <url>` — Sendet einen benutzerdefinierten DNS-Namen im TLS-SNI, der den Host der URI überschreibt.

```bash
h2load -n1000 --sni=example.com https://127.0.0.1:8443/
```

`h2load --ktls <url>` — Aktiviert Kernel-TLS (kTLS) für potenziell verbesserte Performance.

```bash
h2load -n100000 -c100 --ktls https://localhost:8443/
```

## Protokollierung und Ausgabe

`h2load -v <url>` — Aktiviert ausführliche Debug-Ausgabe.

```bash
h2load -v -n10 -c1 https://localhost:8443/
```

`h2load --log-file=<path> <url>` — Schreibt ein Request-Log pro Anfrage (tabulatorgetrennt: Startzeit in µs, HTTP-Status, Antwortzeit in µs). Status −1 bei fehlgeschlagenen Streams.

```bash
h2load -n10000 -c50 --log-file=/tmp/h2load.log https://localhost:8443/
```

`h2load --qlog-file-base=<path> <url>` — Aktiviert qlog-Ausgabe für QUIC-Verbindungen. Dateien werden als base.M.N.sqlog benannt (M=Worker, N=Client).

```bash
h2load -n1000 -c10 --alpn-list=h3 --qlog-file-base=/tmp/qlog https://localhost:443/
```

## Typische Anwendungsmuster

`h2load -n100000 -c100 -m10 <url>` — Standard-HTTP/2-Benchmark: 100K Requests, 100 Clients, 10 parallele Streams.

```bash
h2load -n100000 -c100 -m10 https://localhost:8443/
```

`h2load -c100 -m100 -D 60s --warm-up-time=5s <url>` — Zeitbasierter Test mit Aufwärmphase für stabile Messwerte.

```bash
h2load -c100 -m100 -D 60s --warm-up-time=5s https://localhost:8443/
```

`h2load -n10000 -c10 --h1 <url>` — Vergleicht HTTP/1.1-Performance mit der HTTP/2-Baseline.

```bash
h2load -n10000 -c10 --h1 https://localhost:8443/
```

`h2load -n100000 -c100 -m10 -w16 -W16 <url>` — Benchmark mit HTTP/2-Spec-Standard-Flusskontrollfenstern (64K) statt der großen Standardwerte.

```bash
h2load -n100000 -c100 -m10 -w16 -W16 https://localhost:8443/
```

`for c in 10 50 100 500; do echo "--- $c clients ---"; h2load -n10000 -c$c -m10 <url>; done` — Progressiver Lasttest mit steigenden Parallelitätsstufen.

```bash
for c in 10 50 100 500; do echo "--- $c clients ---"; h2load -n10000 -c$c -m10 https://localhost:8443/; done
```

`h2load -c1 -m1 -n1 -v <url>` — Einzelner Request mit ausführlicher Ausgabe zum Debuggen von Verbindungs- und Protokollaushandlung.

```bash
h2load -c1 -m1 -n1 -v https://localhost:8443/
```

## Einheitenkonventionen

`h2load -D 30s / -D 1m / -D 500ms` — Dauereinheiten: s=Sekunden, m=Minuten, h=Stunden, ms=Millisekunden. Standard (ohne Einheit) sind Sekunden.

`h2load -f 16K / -f 1M / -f 1G` — Größeneinheiten: K=1024, M=1024², G=1024³. Wird für Frame-Größe, Header-Tabellengröße und UDP-Nutzdatengröße verwendet.

<!-- PROSE:outro -->
## Fazit

h2load ist das Werkzeug der Wahl, wenn du HTTP/2-Performance verlässlich messen willst: Die Kombination aus parallelen Streams, Threads und TLS-Kontrolle bildet reale Browserlast besser ab als klassische Tools. Starte mit dem Standardprofil (`-n100000 -c100 -m10`) und justiere Clients und Streams, bis dein Server in die Knie geht.

## Weiterführende Links

- [nghttp2 – offizielle Dokumentation](https://nghttp2.org/documentation/) – Referenz zu h2load und dem gesamten nghttp2-Projekt (englisch)
- [h2load – How-to-Guide](https://nghttp2.org/documentation/h2load-howto.html) – Schritt-für-Schritt-Anleitung und Optionsübersicht (englisch)
<!-- PROSE:outro:end -->

## Verwandte Kommandos

- [ab](https://www.jpkc.com/db/cheatsheets/networking/ab/) – klassisches Apache-Benchmark-Tool für schnelle HTTP-Lasttests
- [wrk](https://www.jpkc.com/db/cheatsheets/networking/wrk/) – moderner HTTP-Benchmark mit Lua-Skript-Unterstützung
- [siege](https://www.jpkc.com/db/cheatsheets/networking/siege/) – Lasttest und Stress-Test für Webserver

