chaos-proxy + chaos-proxy-go

The same chaos model in two runtimes

chaos-proxy is a transport-level HTTP chaos proxy for injecting latency, failures, drops, throttling, and transforms. Both Node.js and Go versions share the same operational model: YAML config, ordered middleware chains, route matching, and runtime reload.

What it does

chaos-proxy runs as a standalone proxy process. You point your HTTP client at it instead of the real upstream, and it applies the chaos rules from a YAML config file before forwarding requests. Because it operates at the transport layer, it works for any HTTP client in any language - your app code does not need to change at all.

Language-agnostic

Any HTTP client - browser, Node.js, Go, Python, curl - can be routed through the proxy without code changes.

Hot-reload config

Send POST /reload to apply a new YAML config at runtime. No restart needed, chaos rules change instantly.

Ready-made presets

Ship with presets for common scenarios: mobile-3g, flaky-backend, burst-errors, timeout-storm. Start in seconds.

Examples

Minimal config

target is the upstream service chaos-proxy forwards to. port is where chaos-proxy itself listens - point your app or tests here instead of the real service.

target: "http://localhost:4000"  # upstream to forward requests to
port: 5000                       # chaos-proxy listens here
global:
  - latency: 100                 # add 100ms to every request

Route-specific chaos

Global rules apply to all traffic. Route rules layer on top, matched by HTTP method and path pattern.

target: "http://localhost:4000"
port: 5000
global:
  - failRandomly:
      rate: 0.05               # 5% of all requests return 503
      status: 503
routes:
  "GET /users/:id":
    - failNth:
        n: 3                   # every 3rd request to this route returns 500
        status: 500
  "POST /orders":
    - latencyRange:
        minMs: 500             # simulate variable upstream slowness
        maxMs: 2000

Using a preset

# start with a ready-made mobile-3g simulation
npx chaos-proxy --config presets/mobile-3g.yaml --verbose

How to use it

Run chaos-proxy alongside your app or test suite. Point your HTTP client at the proxy port instead of the real service. Because nothing in your app code changes, you can toggle chaos on and off just by changing which port you target, or by swapping configs at runtime.

1. Start the proxy

npx chaos-proxy --config chaos.yaml --verbose

2. Point your client at it

# was: http://localhost:4000
# now: http://localhost:5000
fetch('http://localhost:5000/users/123')

3. Reload config without restarting

curl -X POST http://localhost:5000/reload

4. Use programmatically in tests

import { loadConfig, startServer } from 'chaos-proxy'

const server = await startServer(loadConfig('chaos.yaml'))
// run your tests against http://localhost:5000
await server.close()

Node.js vs Go - which one to use?

Both versions share the same YAML config format and middleware model, so you can switch between them without changing your config files. The difference is runtime characteristics and how you install them.

chaos-proxy (Node.js) chaos-proxy-go
Throughput Good ~2x higher - lower latency under load
Memory footprint Higher (Node.js runtime) Minimal - single binary, no runtime
Install npm install chaos-proxy go build or download binary
Programmatic API Yes - TypeScript Yes - Go
Best for JS/Node projects, quick start High-load testing, polyglot teams, CI containers
Config format Identical YAML Identical YAML

If you are already in a Node.js project, start with chaos-proxy. If you are running high-concurrency scenarios, running in a Docker container without Node.js, or testing a Go service, use chaos-proxy-go.

Node.js / TypeScript

Package: chaos-proxy

chaos-proxy npm version chaos-proxy npm downloads chaos-proxy github stars
npm install chaos-proxy
npx chaos-proxy --config chaos.yaml --verbose

Go

Binary + Go API

chaos-proxy-go github stars
go build -o chaos-proxy-go .
./chaos-proxy-go --config chaos.yaml --verbose

Shared capabilities

  • YAML-driven configuration
  • Global and route-level middleware chains
  • Runtime config reload with POST /reload
  • Method + path matching
  • Latency and latencyRange
  • fail / failRandomly / failNth / drops
  • rate limiting and throttling
  • Header/body transforms and optional observability

From the blog