GithubHelp home page GithubHelp logo

davidmr001 / go-redis-memory-analysis Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hhxsv5/go-redis-memory-analysis

0.0 1.0 0.0 443 KB

๐Ÿ”Ž Analyzing memory of redis is to find the keys(prefix) which used a lot of memory, export the analysis result into csv file.

Home Page: http://blog.sina.com.cn/s/blog_9bbafb790102x2sd.html

License: MIT License

Go 100.00%

go-redis-memory-analysis's Introduction

Redis memory analysis

๐Ÿ”Ž Analyzing memory of redis is to find the keys(prefix) which used a lot of memory, export the analysis result into csv file.

Binary File Usage

  1. Download the appropriate binary file from Releases

  2. Run

# help
./redis-memory-analysis-linux-amd64 -h
Usage of ./redis-memory-analysis-darwin-amd64:
  -ip string
    	The host of redis (default "127.0.0.1")
  -password string
    	The password of redis (default "")
  -port uint
    	The port of redis (default 6379)
  -rdb string
    	The rdb file of redis (default "")
  -prefixes string
    	The prefixes list of redis key, be split by '//', special pattern characters need to escape by '\' (default "#//:")
  -reportPath string
    	The csv file path of analysis result (default "./reports")

# run by connecting to redis
./redis-memory-analysis-linux-amd64 -ip="127.0.0.1" -port=6380 -password="abc" -prefixes="#//:"

# run by redis rdb file
./redis-memory-analysis-linux-amd64 -rdb="./6379_dump.rdb" -prefixes="#//:"

Source Code Usage

  1. Install
//cd your-root-folder-of-project
// dep init
dep ensure -add github.com/hhxsv5/go-redis-memory-analysis@~2.0.0
  1. Run
  • Analyze keys by connecting to redis directly.
analysis := NewAnalysis()
//Open redis: 127.0.0.1:6379 without password
err := analysis.Open("127.0.0.1", 6379, "")
defer analysis.Close()
if err != nil {
    fmt.Println("something wrong:", err)
    return
}

//Scan the keys which can be split by '#' ':'
//Special pattern characters need to escape by '\'
analysis.Start([]string{"#", ":"})

//Find the csv file in default target folder: ./reports
//CSV file name format: redis-analysis-{host:port}-{db}.csv
//The keys order by count desc
err = analysis.SaveReports("./reports")
if err == nil {
    fmt.Println("done")
} else {
    fmt.Println("error:", err)
}
  • Analyze keys by redis RDB file, but cannot work out the size of key.
analysis := NewAnalysis()
//Open redis rdb file: ./6379_dump.rdb
err := analysis.OpenRDB("./6379_dump.rdb")
defer analysis.CloseRDB()
if err != nil {
    fmt.Println("something wrong:", err)
    return
}

//Scan the keys which can be split by '#' ':'
//Special pattern characters need to escape by '\'
analysis.StartRDB([]string{"#", ":"})

//Find the csv file in default target folder: ./reports
//CSV file name format: redis-analysis-{host:port}-{db}.csv
//The keys order by count desc
err = analysis.SaveReports("./reports")
if err == nil {
    fmt.Println("done")
} else {
    fmt.Println("error:", err)
}

CSV

Another tool implemented by PHP

redis-memory-analysis

License

MIT

go-redis-memory-analysis's People

Contributors

hhxsv5 avatar

Watchers

 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.