Skip to content

Instantly share code, notes, and snippets.

@koko1000ban
Created August 14, 2014 08:06
Show Gist options
  • Save koko1000ban/79216876e9a722325c4c to your computer and use it in GitHub Desktop.
Save koko1000ban/79216876e9a722325c4c to your computer and use it in GitHub Desktop.
Redis on ruby tunning

Redis Tunning

use hiredis

redis = Redis.new(:host => '127.0.0.1', :driver => :ruby)
10000.times { x = (Benchmark.measure { redis.ping }.real * 1000); puts x if x>1 }

34.964799880981445
53.375959396362305
40.93313217163086
1.0890960693359375
41.39399528503418
38.93303871154785
40.38596153259277
39.68000411987305
38.85602951049805
37.91689872741699
39.18814659118652
40.23027420043945
40.44294357299805
39.92295265197754
38.233280181884766
40.16280174255371
1.2710094451904297
1.2078285217285156
42.5868034362793
42.29307174682617
38.52200508117676
40.489912033081055
40.88187217712402
41.01109504699707
39.026737213134766
40.20977020263672
46.959877014160156
redis = Redis.new(:host => '127.0.0.1', :driver => :hiredis)
10000.times { x = (Benchmark.measure { redis.ping }.real * 1000); puts x if x>1 }

2.1238327026367188
31.930923461914062

thread num

use hiredis driver

# max thread num (current)
redis.set "1", "1"; threads = 36.times.map{ Thread.new{ 1000.times{ x = (Benchmark.measure { redis.get "1" }.real * 1000); puts x if x>10 }}} ; threads.each{|th| th.join };

39.29591178894043
39.38698768615723
39.42084312438965
39.492130279541016
39.53981399536133
39.594173431396484
39.858102798461914
39.9317741394043
40.017127990722656
40.12703895568848
40.17996788024902
40.09699821472168
40.11797904968262
40.099143981933594
40.12274742126465
40.171146392822266
47.40095138549805
50.032854080200195
50.09174346923828
50.19187927246094
50.286054611206055
50.37689208984375
50.45294761657715
50.49705505371094
.
.
.
ものすごくたくさん

redis.set "1", "1"; threads = 7.times.map{ Thread.new{ 1000.times{ x = (Benchmark.measure { redis.get "1" }.real * 1000); puts x if x>10 }}} ; threads.each{|th| th.join };

58.32719802856445
58.450937271118164
58.5331916809082
58.60781669616699
58.63690376281738
59.35382843017578
@koko1000ban
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment