These assets are provided to show how to configure Envoy outlier detection in HashiCorp Consul to implement a circuit breaker for an application in a service mesh.
- Docker Compose
- Docker
curl
The following files are provided as demo scripts:
start.sh
: Starts Consul, three services (web
,api-v1
,api-v2
) with proxies, and Prometheus (for metrics).fail.sh
: Enables error rates forapi-v2
service.success.sh
: Disables error rates forapi-v2
service for successful calls.request.sh
: Make repeated API calls to theweb
service to trigger the circuit breaker.cleanup.sh
: Removes all of the instances.
NOTE: DON'T FORGET that this demo requires Docker Compose!
-
Run
start.sh
. This starts Consul in development mode and registers three services,web
,api-v1
, andapi-v2
. It also starts Prometheus to aggregate metrics. -
Run
fail.sh
. This toggles an error setting inapi-v2
to mimic an error. -
Run
request.sh
to issue 100 API requests against theweb
service. Since outlier detection is enabled, you will find that the circuit breaker will open and divert all traffic toapi-v1
while occasionally sending a request toapi-v2
to check its availability. -
In another terminal, run
success.sh
. This will close the circuit breaker and once more divert traffic to bothapi-v1
andapi-v2
.
Finally, run cleanup.sh
to re-set your environment so that you can repeat the demo as necessary.
WARNING: The
cleanup.sh
removes all instances.