Skip to content

Instantly share code, notes, and snippets.

@ArturT
Created September 22, 2023 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArturT/5d9bcd7213806f731cfb812363ae5b82 to your computer and use it in GitHub Desktop.
Save ArturT/5d9bcd7213806f731cfb812363ae5b82 to your computer and use it in GitHub Desktop.
Measure Redis latency from inside of Heroku Dyno
# repalce REDIS_CONNECTION with your Redis instance
#
# run this script in Rails console.
# For example start Heroku Dyno with Rails console to measure the Redis latency from inside of the Heroku Dyno
#
# Do you like it? Check what we do: https://knapsackpro.com
rtts = []
100.times do
a = b = 0; a = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC, :microsecond); REDIS_CONNECTION.ping; b = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC, :microsecond); rtt = b - a;
puts "#{rtt} microseconds"
rtts << rtt
sleep 0.1
end
puts "Average: #{rtts.sum / rtts.size.to_f}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment