memcache and redis, Mongodb advantages and disadvantages and application scenarios

1.mongodb port (27017)

(1) is a document type of non-relational databases, using bson structure. The advantage is that the query more powerful, capable of storing huge amounts of data, the disadvantage is relatively consume memory.

(2) review the like may be generally used to store semi-structured data, to support the secondary index. Json type adapted to store data, does not change frequently.

  Advantages :

  • Document storage structure can be more convenient access to data
  • Built-in GridFS, support large capacity storage
  • Built Sharding, simple fragment
  • The massive data, superior performance
  • Supports automatic failover (replication set)

  Disadvantages :

  • It does not support transactional operations
  • Take up too much space
  • MongoDB is not as sophisticated maintenance tool such as MySQL
  • Can not be associated query, does not apply to multi-relational data
  • Mapreduce polymerization operation by creating a complex, slow
  • Bring the free mode, the freedom and flexibility of file storage format data error

  Application scenarios :

     

2.redis port (6379)

(1) the memory database, the data stored in memory, direct access through tcp, the advantage is high read and write performance.

(2) redis KV-memory database is (key-value store database, which data is organized, indexed, stored key-value pairs in accordance with the situation), the secondary index is not supported, support list, set and other data formats. Suitable for storing global variables for reading and writing less business scenarios. It is suitable for caching.

   Advantages :

  • It supports multiple data types string, list, set, zset, hash
  • Data can remain persistent (AOF, snapshots), written to disk,
  • Support disaster recovery, master-slave replication. Host will automatically synchronize data to the slave, separate read and write may be performed.
  • Good read and write performance.

   Disadvantages :

  • redis does not support automatic fault tolerance and recovery, when the master and slave machines will lead to failure of the reader front end, the front end of the need to manually reboot the machine or Ip
  • Host down, from the master data replication process, the data is not completely copied to the slave, data inconsistency occurs.
  • redis difficult to support online expansion, when the group reached the limit of data online expansion is complicated.

   Application scenarios :

  • Relational databases do with the cache
  • High frequency data buffer, decrease database io
  • Distributed architecture, do share session

   example:

     For example micro-channel token refresh every two hours, is more suitable for redis storage, read more convenient;

     Online game rankings; timing display relevant ads after a certain time; time according to user voting and sorting, updating news;

     Specific statistics on the number of users accessing a particular resource, which access a particular user statistics on a post articles at a certain characteristic time;

 

3.Memcached is a high-performance distributed memory object caching system for dynamic Web applications to reduce database load. It is to reduce the number of cache data read from the database by the object in memory and to provide a dynamic, speed of the database-driven websites. Memcached based on a store key / value pairs hashmap. Port (11211)

   Advantages :

  • Part of disaster recovery: Suppose only one memcache, if this memcache server hung up, then the request will continue to impact the database, so it is possible Gaosi database, giving rise to "an avalanche." If you use multiple memcache servers, because the memcache using a consistent hashing algorithm, in case one of them hung up, or may be part of the request hits in memcache, in order to repair the system to win some time.
  • Capacity issues: a memcache server capacity is limited, you can use multiple memcache servers, increasing the cache size.
  • Equilibrium request: use multiple memcache servers, you can request a balanced and avoid all requests are rushed into a memcache server, causing the server to hang.
  • Using memcache distributed nature: memcache using a server, the distributed nature of the data and does not use the memcache.

   Disadvantages :

  • Storage can not be sustained
  • Data storage is limited: 1M [greater than 1M, consider dividing line] (memory chips)
  • mm key-value store data only
  • Cluster data replication and synchronization mechanism [no crash will not affect the program will fetch data from the database]
  • Memory can not be recovered in time LRU (algorithm): Unused Memory "expired Memory" least recently used memory which is inert to delete

   Application scenarios :

  • Distributed Cache
  • Database preceding cache
  • Data sharing between servers

 

Guess you like

Origin www.cnblogs.com/mzhaox/p/11308840.html