Skip to content

Instantly share code, notes, and snippets.

@jhubert
Last active July 21, 2016 00:16
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 jhubert/2a5a1889a77693d4c1c62a0e145dcea5 to your computer and use it in GitHub Desktop.
Save jhubert/2a5a1889a77693d4c1c62a0e145dcea5 to your computer and use it in GitHub Desktop.
Benchmarking memcachier and redis-cloud from your heroku instance

I did some performance testing from heroku to memcachier and redis-cloud to check the iterations per second. Here is how I did it, based on the work that @nateberkopec did:

From heroku run bash -r production run the following:

gem install benchmark-ips --no-doc --no-ri
gem install redis-activesupport --no-doc --no-ri
# the other gems are already installed because they're included in our app's gemfile, but you may need:
# gem install dalli --no-doc --no-ri
# gem install rails --no-doc --no-ri

and then paste this script into an irb console:

require 'active_support'
require 'benchmark/ips'
require 'dalli'
require 'active_support/cache/dalli_store'
require 'active_support/cache/redis_store'

KEY_SIZE = 2_000

Benchmark.ips do |x|
  dc_networked = ActiveSupport::Cache::DalliStore.new(ENV['MEMCACHIER_SERVERS'], username: ENV['MEMCACHIER_USERNAME'], password: ENV['MEMCACHIER_PASSWORD'])
  dc_networked.clear
  x.report("#{dc_networked.class} at #{ENV['MEMCACHIER_SERVERS']}") do
    dc_networked.fetch(rand(KEY_SIZE)) { :value }
  end

  redis_networked = ActiveSupport::Cache::RedisStore.new(ENV['REDISCLOUD_URL'])
  redis_networked.clear
  x.report("#{redis_networked.class} at #{URI.parse(ENV['REDISCLOUD_URL']).host}") do
    redis_networked.fetch(rand(KEY_SIZE)) { :value }
  end
end

Here are the results:


Warming up --------------------------------------
ActiveSupport::Cache::DalliStore at mc2.dev.ec2.memcachier.com:11211
                        40.000  i/100ms
ActiveSupport::Cache::RedisStore at pub-redis-16974.us-east-1-4.1.ec2.garantiadata.com
                        37.000  i/100ms
Calculating -------------------------------------
ActiveSupport::Cache::DalliStore at mc2.dev.ec2.memcachier.com:11211
                        451.147  (±21.9%) i/s -      2.120k in   5.034654s
ActiveSupport::Cache::RedisStore at pub-redis-16974.us-east-1-4.1.ec2.garantiadata.com
                        553.988  (±14.6%) i/s -      2.738k in   5.059287s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment