simulate a slow connection with toxiproxy

Developer from somewhere

Toxiproxy.populate([
  {
    name: "toxiproxy_test_redis_tags",
    listen: "127.0.0.1:22222",
    upstream: "127.0.0.1:6379"
  }
])

r = Redis.new(port: 22222)

Toxiproxy["toxiproxy_test_redis_tags"].downstream(:latency, latency: 5000).apply do
  puts Time.now
  puts "Value is", r.get("ok")
  puts Time.now
end

Toxiproxy["toxiproxy_test_redis_tags"].upstream(:timeout, timeout: 2000).apply do
  # whatever
end

The example above would give you a “slow” redis. I received the following error on my system:

Unit toxiproxy.service failed to load

when trying to start toxiproxy via:

sudo service toxiproxy start

But, you can just start it manually. Do a updatedb and then a locate toxiproxy in case you don’t know where your binary is, and then you can populate it like in the example above.