Skip to main content
Quick navigation

Chaos Simulate Slow Producers & Consumers

This interceptor simulates slow responses from brokers, but only on a set of topics rather than all traffic.

This demo will run you through some of these use cases step-by-step.

View the full demo in realtime

You can either follow all the steps manually, or watch the recording

Review the docker compose environment

As can be seen from docker-compose.yaml the demo environment consists of the following services:

  • gateway1
  • gateway2
  • kafka-client
  • kafka1
  • kafka2
  • kafka3
  • schema-registry
cat docker-compose.yaml

Starting the docker environment

Start all your docker processes, wait for them to be up and ready, then run in background

  • --wait: Wait for services to be running|healthy. Implies detached mode.
  • --detach: Detached mode: Run containers in the background
docker compose up --detach --wait

Creating topic slow-topic on gateway1

Creating on gateway1:

  • Topic slow-topic with partitions:1 and replication-factor:1
kafka-topics \
--bootstrap-server localhost:6969 \
--replication-factor 1 \
--partitions 1 \
--create --if-not-exists \
--topic slow-topic

Adding interceptor simulate-slow-producer-consumers

Let's create the interceptor, instructing Conduktor Gateway to simulate slow responses from brokers, but only on a set of topics rather than all traffic.

step-06-simulate-slow-producer-consumers-interceptor.json:

{
"kind" : "Interceptor",
"apiVersion" : "gateway/v2",
"metadata" : {
"name" : "simulate-slow-producer-consumers"
},
"spec" : {
"comment" : "Adding interceptor: simulate-slow-producer-consumers",
"pluginClass" : "io.conduktor.gateway.interceptor.chaos.SimulateSlowProducersConsumersPlugin",
"priority" : 100,
"config" : {
"topic" : "slow-topic",
"rateInPercent" : 100,
"minLatencyMs" : 3000,
"maxLatencyMs" : 3001
}
}
}
curl \
--silent \
--request PUT "http://localhost:8888/gateway/v2/interceptor" \
--header "Content-Type: application/json" \
--user "admin:conduktor" \
--data @step-06-simulate-slow-producer-consumers-interceptor.json | jq

Listing interceptors

Listing interceptors on gateway1

curl \
--silent \
--request GET "http://localhost:8888/gateway/v2/interceptor" \
--user "admin:conduktor" | jq

Let's produce some records to our created topic

9 records sent, 1,6 records/sec (0,00 MB/sec), 3168,2 ms avg latency, 4840,0 ms max latency. 71 records sent, 11,1 records/sec (0,00 MB/sec), 3287,0 ms avg latency, 4749,0 ms max latency. 100 records sent, 7,811279 records/sec (0,00 MB/sec), 3278,28 ms avg latency, 4840,00 ms max latency, 3180 ms 50th, 4440 ms 95th, 4840 ms 99th, 4840 ms 99.9th.

kafka-producer-perf-test \
--producer-props \
bootstrap.servers=localhost:6969 \
--record-size 10 \
--throughput 1 \
--num-records 10 \
--topic slow-topic

Tearing down the docker environment

Remove all your docker processes and associated volumes

  • --volumes: Remove named volumes declared in the "volumes" section of the Compose file and anonymous volumes attached to containers.
docker compose down --volumes

Conclusion

Yes, Chaos Simulate Slow Producers and Consumers is simple as it!