GithubHelp home page GithubHelp logo

zph / redis-transfer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adarqui/redis-transfer

1.0 2.0 0.0 119 KB

a simple tool to transfer (dump/restore) keys from one redis to another, using go (massive thread capable), and a beast progress bar.. eeeeeuugg.

License: Other

Makefile 1.29% Go 98.71%

redis-transfer's Introduction

redis-transfer

Concurrent bulk transfer of keys from one redis server to another.

What it does?

Parallelizes the transfer of redis keys from a source to a target redis server. You can specify what keys to transfer via regex or from an input file which contains a list of keys. Redis-transfer will then spawn N go routines (threads) which pull (dump) keys from the source redis server & immediately push (restore) those keys to the target redis. As a bonus, gives you a pretty progress bar.

Usage

 $ ./redis-transfer
usage: redis-transfer <from_redis> <to_redis> <regex_or_input_file> <concurrent_threads>

 * There are two redis connection formats to choose from:
   - host:port:[db[:password]]
   - redis://user:password@host:port?db=number

 * regex_or_input_file:
   - To transfer only those keys that match a regex pattern:
     some_key_prefix*
     *some_key_suffix
     prefix*something*suffix
     etc..

   - To transfer keys from an input file, simply list keys in a file, separated by newlines
     key1
     keyN

 * concurrent_threads:
   - This should be a number between 1 and (max_cpu's*10)
     You can play around with this to find the optimal setting. I generally use 50 on my 8 core box.

 * examples:
   redis-transfer localhost:6379 remotehost:6379:1:password "migrate:*" 50
   redis-transfer redis://localhost:6379 redis://user:password@remotehost?db=1 "migrate:*" 50

Example benchmark output

Note: Experiment performed in ~2013. Go has made significant improvements since then. Expect better results.

The example progress bar output below illustrates the difference we see specific to the concurrency level. Transferring 5 million keys using 40 concurrent threads between two servers (across the internet) took approximately 10 minutes in this experiment. Not surprisingly, using only one thread took approximately 40 minutes.

40 Threads

80973 / 5000000 [>--------------------------------------------------------------] 1.62 % 8066/s 10m9s

10 Threads

108367 / 5000000 [==>-----------------------------------------------------------] 2.17 % 6457/s 12m37

1 Thread

4124 / 5000000 [>---------------------------------------------------------------] 0.08 % 2059/s 40m26

Todo

  • Add optional params via flags.
  • With flags, add the ability to pass '--replace' which would replace existing keys.
  • Deeper refactor.

Contributing

Pull requests welcome!

See CONTRIBUTORS.

redis-transfer's People

Contributors

adarqui avatar zph avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.