Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Database \ How to statistical data of various size Redis     - Ubuntu compiler installation R Full Record (Linux)

- Java look and feel mode (Facade mode) (Programming)

- Encrypted with GnuPG signature to verify the authenticity and integrity of downloaded file (Linux)

- Linux Command study manual - GPG command (Linux)

- Restrict console access to Linux servers to improve security (Linux)

- CentOS6 installation configuration rsh (Server)

- Python system default encoding (Programming)

- Based Corosync + Pacemaker + DRBD + LNMP Web server to achieve high availability cluster (Server)

- iOS Sensor Development - add to APP phone password, fingerprint security authentication (Programming)

- Git / Github use notes (Linux)

- Analysis of Java in the deep copy and shallow copy (Programming)

- Several Ceph performance optimization of new methods and ideas (2015 SH Ceph Day after flu reference) (Server)

- Mac Docker deploy development environment (Server)

- Linux NFS FTP use (Server)

- Linux environment password security settings (Linux)

- Applications Linux leap second problem caused (Linux)

- Use Visual Studio Code Development TypeScript (Linux)

- DB2 commonly used scripting sort out (Database)

- Ubuntu modify DNS restart loss problem (Linux)

- Oracle 10g relations with the constraint of column properties NULLABLE (Database)

 
         
  How to statistical data of various size Redis
     
  Add Date : 2018-11-21      
         
         
         
  If MySQL database is relatively large, we can easily find out what the space occupied by the table; but if Redis memory is relatively large, we are not easy to find out what (kind of) the space occupied by the key.

There are tools to provide the necessary assistance, such as redis-rdb-tools can analyze RDB file to generate a report, but it can not be a hundred percent to achieve my needs, but I do not want it on the basis of secondary development. In fact the development of a special tool is very simple, use SCAN and DEBUG commands, did not realize how many lines of code:

< ? Php

$ Patterns = array (
    'Foo:. +',
    'Bar:. +',
    '+',
);

$ Redis = new Redis ();
$ Redis-> setOption (Redis :: OPT_SCAN, Redis :: SCAN_RETRY);

$ Result = array_fill_keys ($ patterns, 0);

while ($ keys = $ redis-> scan ($ it, $ match = '*', $ count = 1000)) {
    foreach ($ keys as $ key) {
        foreach ($ patterns as $ pattern) {
            if (preg_match ( "/ ^ {$ pattern} $ /", $ key)) {
                if ($ v = $ redis-> debug ($ key)) {
                    $ Result [$ pattern] + = $ v [ 'serializedlength'];
                }

                break;
            }
        }
    }
}

var_dump ($ result);

?>
Of course, the premise is that you may need to summarize the key patterns in advance, but simple approach is not rigorous MONITOR:

shell> / path / to / redis-cli monitor |
       awk -F ' "' '$ 2 ~" ADD | SET | STORE | PUSH "{print $ 4}'
In addition, note that: because DEBUG returned serializedlength length serialized, so the value of the final calculation is less than the actual memory footprint, but taking into account the relative size of the reference is still significant.
     
         
         
         
  More:      
 
- Graphics of Java Tools (Programming)
- Summary Linux bond of multi-interface load balancing (Linux)
- Upgrading KDE Plasma 5.3 in Ubuntu 15.04 (Linux)
- Ubuntu will be written in a command file, executable file, source command (Linux)
- STL spatial Configurator (Programming)
- Kubuntu 14.04 desktop to the user how to upgrade KDE 4.13.2 (Linux)
- Unable to start the network after restart clone a virtual machine (Linux)
- Ubuntu users to install Gnome-Pie 0.6.5 (Linux)
- By way of a binary installation innobackupex (Database)
- Linux platform to prevent hackers to share practical skills (Linux)
- Open MySQL slow query log (Database)
- MySQL database under Linux to achieve automatic backup scheduled backup day (Database)
- Linux kernel to achieve soft RPS network to receive soft interrupt load balancing to distribute (Linux)
- Linux data recovery software efficiently practical application extundelete (Linux)
- Nginx-1.9.7 TCP reverse proxy (Server)
- MySQL import large amounts of data (Database)
- Django1.8 return json json string and the string contents of the received post (Programming)
- Python Socket Network Programming (Programming)
- Access clipboard content across multiple vim instances in a terminal (Linux)
- stat - Get more information than ls (Linux)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.