diff options
author | antirez <antirez@gmail.com> | 2015-12-11 18:10:40 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2015-12-11 18:12:56 +0100 |
commit | f0b168e8944af41c4161249040f01ece227cfc0c (patch) | |
tree | 065ae1fa72729e4ca9ba686ccb9d9a907d56dbae /src/redis-trib.rb | |
parent | 4e252e4c099b4d8e160bc196e1a2124d6e0cb79d (diff) | |
download | redis-f0b168e8944af41c4161249040f01ece227cfc0c.tar.gz |
Cluster: redis-trib: use variadic MIGRATE.
We use the new variadic/pipelined MIGRATE for faster migration.
Testing is not easy because to see the time it takes for a slot to be
migrated requires a very large data set, but even with all the overhead
of migrating multiple slots and to setup them properly, what used to
take 4 seconds (1 million keys, 200 slots migrated) is now 1.6 which is
a good improvement. However the improvement can be a lot larger if:
1. We use large datasets where a single slot has many keys.
2. By moving more than 10 keys per iteration, making this configurable,
which is planned.
Close #2710
Close #2711
Diffstat (limited to 'src/redis-trib.rb')
-rwxr-xr-x | src/redis-trib.rb | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/redis-trib.rb b/src/redis-trib.rb index 7ab4221c5..74f3e214e 100755 --- a/src/redis-trib.rb +++ b/src/redis-trib.rb @@ -818,22 +818,20 @@ class RedisTrib while true keys = source.r.cluster("getkeysinslot",slot,10) break if keys.length == 0 - keys.each{|key| - begin - source.r.client.call(["migrate",target.info[:host],target.info[:port],key,0,@timeout]) - rescue => e - if o[:fix] && e.to_s =~ /BUSYKEY/ - xputs "*** Target key #{key} exists. Replacing it for FIX." - source.r.client.call(["migrate",target.info[:host],target.info[:port],key,0,@timeout,:replace]) - else - puts "" - xputs "[ERR] #{e}" - exit 1 - end + begin + source.r.client.call(["migrate",target.info[:host],target.info[:port],"",0,@timeout,:keys,*keys]) + rescue => e + if o[:fix] && e.to_s =~ /BUSYKEY/ + xputs "*** Target key #{key} exists. Replacing it for FIX." + source.r.client.call(["migrate",target.info[:host],target.info[:port],"",0,@timeout,:replace,:keys,*keys]) + else + puts "" + xputs "[ERR] #{e}" + exit 1 end - print "." if o[:verbose] - STDOUT.flush - } + end + print "."*keys.length if o[:verbose] + STDOUT.flush end puts |