Simulate Poor Network Conditions
Ce contenu n’est pas encore disponible dans votre langue.
This guide explains how to use the staged toxic proxy setup to simulate poor network conditions when developing Open Data Capture.
When you run scripts/toxic-proxy.sh, it configures Toxiproxy with the following simulated network conditions:
- Downstream bandwidth limit (API → browser): capped at 5,000 KB/second (~5 MB/s).
- Upstream bandwidth limit (browser → API): capped at 2,500 KB/second (~2.5 MB/s).
- Intermittent latency and jitter (downstream):
- Base latency of 50 ms, plus up to 500 ms of jitter.
- Applied with 20% toxicity, meaning only about 1 in 5 downstream requests/responses are delayed in this way.
- Occasional random connection resets (downstream):
- Connections are randomly reset/closed from the proxy side.
- Applied with 10% toxicity, so roughly 1 in 10 downstream connections will be abruptly terminated.
Together, these toxics approximate a slow, unstable network where responses arrive slowly, some requests suffer extra delay, and a minority of connections fail unexpectedly.
Prerequisites
- Install Toxiproxy (both
toxiproxy-serverandtoxiproxy-cli) and ensure they are available on yourPATH.
Steps
-
Set the toxic proxy port in
.envChoose a port for the toxic proxy (for example
5501) and set:API_DEV_TOXIC_PROXY_PORT=5501
-
Point the frontend at the toxic proxy
Update
API_BASE_URLto use the same port on localhost:API_BASE_URL=http://localhost:5501
-
Start the toxic proxy
Run:
Terminal window scripts/toxic-proxy.shLeave this running. It creates a proxy that sits between the frontend and the API server and applies bandwidth limits.
-
Launch the app as normal
In another terminal, run:
Terminal window pnpm dev
Notes
- The proxy reads
API_DEV_SERVER_PORTfrom.envto know where your API server is listening. - If
API_DEV_TOXIC_PROXY_PORTis empty, the script exits without starting the proxy.