1. What are the benefits of using Redis?
(1) Fast, because the data exists in memory, similar to the Hashmap,hashmap advantage is to find and manipulate the time complexity is O (1)
(2) Support rich data type, support string,list,set,sorted Set,hash
(3) Support transactions, operations are atomic, the so-called atomicity is to change the data is either fully executed, or all do not execute
(4) Rich features: can be used for caching, messages, set the expiration time by key, will be automatically deleted after expiration
2. What are the advantages of Redis compared to memcached?
(1) memcached All values are simple strings, redis as their replacement, support for richer data types
(2) Redis speed is much faster than memcached
(3) Redis can persist its data
3. Redis Common performance problems and solutions:
(1) Master is best not to do any persistent work, such as RDB memory snapshots and aof log files
(2) If the data is more important, a slave to open aof backup data, the policy is set to sync once per second
(3) In order to master the speed of replication and the stability of the connection, master and slave best in the same LAN
(4) As far as possible to avoid the pressure of a large main library to increase from the library
(5) Master-slave copy do not use a graph structure, with one-way linked list structure more stable, namely: Master <-Slave1 <-Slave2 <-Slave3 ...
Such a structure facilitates the resolution of a single point of failure and realizes the replacement of Master slave. If master hangs, you can immediately enable Slave1 to do master, other unchanged.
(a) Redis recycling strategy
VOLATILE-LRU: Select the least recently used data elimination from the set Expiration data set (Server.db[i].expires)
Volatile-ttl: Select the obsolete data set (Server.db[i].expires) from the set expiration date
Volatile-random: Arbitrary selection of data obsolescence from a set of expired data sets (Server.db[i].expires)
ALLKEYS-LRU: Select the least recently used data from the dataset (server.db[i].dict) obsolescence
Allkeys-random: Arbitrary selection of data elimination from datasets (SERVER.DB[I].DICT)
No-enviction (expulsion): Prohibition of expulsion data