Skip to content

Instantly share code, notes, and snippets.

@patrobinson
Created February 5, 2019 00:16
Show Gist options
  • Save patrobinson/744bb0ff8ab66f605425f43185edebc9 to your computer and use it in GitHub Desktop.
Save patrobinson/744bb0ff8ab66f605425f43185edebc9 to your computer and use it in GitHub Desktop.
Test how long an ElastiCache Redis Failover takes before the app reconnects
require 'redis'
$redis = Redis.new({url: ENV['REDIS_HOST']})
puts $redis.connected?
failed = false
starting = nil
ending = nil
loop do
$redis.ping
if failed
ending = Time.now
puts ending - starting
break
end
rescue => e
puts e
starting = Time.now unless failed
failed = true
retry
end
require 'redis'
require 'semian/redis'
$redis = Redis.new({url: ENV['REDIS_HOST'], semian: {
name: "inventory",
tickets: 4,
success_threshold: 2,
error_threshold: 4,
error_timeout: 20
}})
puts $redis.connected?
failed = false
starting = nil
ending = nil
loop do
$redis.ping
if failed
ending = Time.now
puts ending - starting
break
end
rescue => e
puts e
starting = Time.now unless failed
failed = true
retry
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment