Redis is a high-performance Key-value database. The emergence of redis largely compensates for the shortage of keyValue storage such as memcached, and can play a very good complementary role in relational databases. It provides python, Ruby, Erlang, and PHP clients for ease of use. The problem is that this project is still quite new and may not be stable enough, and there are no actual instances for large-scale system applications. In addition, the lack of batch get in MC is also a big problem. The network overhead of batch get is different from that of multiple get.
Performance test results:
The set operation is performed 110000 times per second, and the get operation is performed 81000 times per second. The server configuration is as follows:
For Linux 2.6,Xeon x33 20 2.5 GHz.
Jredis is a high-performance Java client that connects to the redis distributed Hash key-value database. Provides synchronous and asynchronous connections.
Redis for windows can be downloaded here. It is not an official version.
Http://code.google.com/p/servicestack/wiki/RedisWindowsDownload
The redis folder contains the following files:
Redis-server.exe: service programs
Specify the redis configuration file. If not specified, use the default settings.
D:/redis-2.0.0-rc2> redis-server.exe for redis. conf
The redis. conf configuration options are as follows:
Whether daemonize is run by a later process. The default value is no.
If pidfile is run by a later process, you must specify a PID. The default value is/var/run/redis. PID.
Bind Host IP address. Default Value: 127.0.0.1 (note)
Port listening port. The default value is 6379.
Timeout timeout. The default value is 300 seconds)
Loglevel log record level, which has four optional values: Debug, verbose (default), notice, and warning
Logfile logging method. The default value is stdout.
Number of available databases in databases. The default value is 16 and the default value is 0.
Save indicates how many update operations are performed within a specified period of time, and the data is synchronized to the data file. This can be used with multiple conditions. For example, three conditions are set in the default configuration file.
Save 900 1 900 seconds (15 minutes) at least one key is changed
Save 300 10 300 seconds (5 minutes) at least 300 keys are changed
Save 60 10000 at least 10000 keys are changed within 60 seconds
Whether the data is compressed when rdbcompression is stored in the local database. The default value is yes.
Dbfilename: name of the local database file. The default value is dump. RDB.
Path for storing the Dir local database. The default value is ./
Slaveof when the local machine is a slave service, set the IP address and port of the master service (note)
Masterauth when the local machine is a slave service, set the master service connection password (comment)
Requirepass connection password (note)
Maxclients maximum number of client connections, no limit by default (note)
When maxmemory sets the maximum memory to reach the maximum memory setting, redis will first try to clear expired or expiring keys. After this method is processed, it will reach the maximum memory setting, no more write operations can be performed. (Note)
Whether appendonly records logs after each update operation. If it is not enabled, data may be lost for a period of time during power failure. Because redis synchronizes data files according to the Save conditions above, some data will only exist in the memory for a period of time. The default value is no.
Appendfilename: update the log file name. The default value is appendonly. aof (comment)
Appendfsync updates log conditions. There are three optional values. "No" indicates that data is cached and synchronized to the disk by the operating system. "Always" indicates that data is manually written to the disk by calling fsync () after each update operation. "everysec" indicates that data is synchronized once per second (default ).
Whether VM-enabled uses virtual memory. The default value is no.
VM-Swap-file: virtual memory file path. The default value is/tmp/redis. Swap. It cannot be shared by multiple redis instances.
VM-max-memory stores all data greater than VM-max-memory into the virtual memory, no matter how small the VM-max-memory settings are, all index data is stored in memory (redis index data is keys). That is to say, when VM-max-memory is set to 0, all values are actually stored on the disk. The default value is 0.
The official redis documentation provides some suggestions for the use of VMS:
When your key is very small and the value is very large, it will be better to use the VM, because the memory saved is relatively large.
When your key is not hour, you can consider using some very method to convert a large key into a large value. For example, you can consider combining the key and value into a new value.
It is best to use Linux ext3 and other file systems that support sparse files to save your swap files.
The VM-max-threads parameter can be used to set the number of threads accessing the swap file. It is best to set the number of threads not to exceed the number of machine cores. if it is set to 0, all operations on swap files are serial. it may cause a long delay, but it guarantees data integrity.
Redis-cli.exe: command line client for testing
D:/redis-2.0.0-rc2> redis-cli.exe-H 127.0.0.1-P 6379
Set a key and obtain the returned value:
$./Redis-cli set mykey somevalue
OK
$./Redis-cli get mykey
Somevalue
How to add values to list:
$./Redis-cli lpush mylist firstvalue
OK
$./Redis-cli lpush mylist secondvalue
OK
$./Redis-cli lpush mylist thirdvalue
OK
$./Redis-cli lrange mylist 0-1
1. thirdvalue
2. secondvalue
3. firstvalue
$./Redis-cli rpop mylist
Firstvalue
$./Redis-cli lrange mylist 0-1
1. thirdvalue
2. secondvalue
Redis-check-dump.exe: local database check
Redis-check-aof.exe: Update log check
Redis-benchmark.exe: Performance Testing to simulate sending M sets/gets queries simultaneously by N clients (similar to Apache's AB tool ).
./Redis-benchmark-N 100000-C 50
===== Set ======
100007 requests completed in 0.88 seconds (Translator's note: 100004 the query is completed in 1.14 seconds)
50 parallel clients (Translator's note: 50 concurrent clients)
3 bytes Payload)
Keep alive: 1 (Translator's note: Keep one connection)
58.50% <= 0 milliseconds (in milliseconds)
99.17% <= 1 milliseconds
99.58% <= 2 milliseconds
99.85% <= 3 milliseconds
99.90% <= 6 milliseconds
100.00% <= 9 milliseconds
114293.71 requests per second (Translator's note: 114293.71 queries per second)
The maximum number of concurrent clients tested in Windows is 60.
Related Articles
Http://www.rediscn.com/index.html
Http://code.google.com/p/redis/ (official website)
Reprint please indicate the source: http://www.madcn.net /? P = 686