SECTOR 03 // REFERENCE

toxiproxy

Proxy-in-path network faults: latency, packet loss, bandwidth, blackhole, timeout, and partition, each scoped to a stream direction.

Proxy-in-path network faults. Drives the Toxiproxy admin API through the official Go client. Each verb names a proxy already configured in Toxiproxy and adds (or clears) a toxic on it, so the fault sits in the request path between the client and the backend.

providers:
  toxiproxy:
    config:
      adminUrl: http://localhost:8474

adminUrl is the Toxiproxy admin API. Every verb returns "ok" as the value (reset returns "reset"), with an empty output and meta.

Direction #

A proxied connection is bidirectional, and the toxic verbs (add_latency, packet_loss, bandwidth, blackhole, timeout) take an optional direction choosing which leg they degrade:

valueleguse
from_serverservice to client (default)responses, jobs, and keepalives flowing to the client
to_serverclient to servicerequests, and the path a worker uses to send results back
botheach leginstalls the toxic on both streams

from_server preserves the original single-direction behavior, so existing scenarios are unaffected. The toxiproxy-native names downstream and upstream are accepted as aliases of from_server and to_server. Faulting only to_server slows or cuts the result-send path while responses keep flowing, so the peer is never marked dead. partition and reset act on the whole connection and ignore direction.

Verbs #

add_latency (action, degradation) #

Adds a downstream latency toxic: data is delayed, not dropped.

argtypereqdescription
proxystringyesthe configured proxy to slow (primary)
latencyMsnumberyesadded latency in milliseconds
jitterMsnumbernorandom jitter added to the latency
directionstringnowhich leg to slow (see Direction, default from_server)
- run: toxiproxy.add_latency
  with: { proxy: db, latencyMs: 300, jitterMs: 50 }

packet_loss (action, outage) #

Drops a fraction of data without closing connections, so calls stall and time out rather than failing fast.

argtypereqdescription
proxystringyesthe configured proxy to degrade (primary)
toxicitynumbernofraction of data affected, 01 (default 1.0)
directionstringnowhich leg to degrade (see Direction, default from_server)
- run: toxiproxy.packet_loss
  with: { proxy: db, toxicity: 0.3 }

bandwidth (action, degradation) #

Throttles throughput to a fixed rate.

argtypereqdescription
proxystringyesthe configured proxy to throttle (primary)
rateKbpsnumberyesthroughput cap in kilobits per second
directionstringnowhich leg to throttle (see Direction, default from_server)
- run: toxiproxy.bandwidth
  with: { proxy: db, rateKbps: 256 }

blackhole (action, outage) #

Drops all data while leaving the socket open, so connections hang.

argtypereqdescription
proxystringyesthe configured proxy to black-hole (primary)
directionstringnowhich leg to black-hole (see Direction, default from_server)
- run: toxiproxy.blackhole
  with: db

To hold a result in flight and then drop it without tripping dead-peer detection, latency then blackhole the to_server leg while responses keep flowing:

- run: toxiproxy.add_latency
  with: { proxy: backend, latencyMs: 5000, direction: to_server }
- run: toxiproxy.blackhole
  with: { proxy: backend, direction: to_server }

timeout (action, outage) #

Drops all data and then closes the connection after the interval, so a call wedges and is torn down after a bounded wait. This differs from blackhole, which holds the socket open indefinitely.

argtypereqdescription
proxystringyesthe configured proxy to wedge (primary)
timeoutMsnumberyeswait before the connection is closed, in milliseconds
directionstringnowhich leg to wedge (see Direction, default from_server)
- run: toxiproxy.timeout
  with: { proxy: db, timeoutMs: 2000 }

partition (action, outage) #

Disables the proxy entirely, so connections fail fast.

argtypereqdescription
proxystringyesthe configured proxy to disable (primary)
- run: toxiproxy.partition
  with: db

clear (action) #

Scoped recovery: removes this proxy’s toxics and re-enables it (undoing a partition), leaving every other proxy untouched. Use it to lift a fault from one connection without disturbing the rest of the run.

argtypereqdescription
proxystringyesthe configured proxy to restore (primary)
- run: toxiproxy.clear
  with: db

reset (action) #

Global recovery: removes all toxics and re-enables every proxy. Unlike clear, it acts on every proxy at once.

No args.

- run: toxiproxy.reset