Home  >  Q&A  >  body text

memcached - redis、memcache、mongoDB有哪些区别?

redis、memcache、mongoDB有哪些区别?例如:性能、可靠性、数据一致性等方面的区别。

ringa_leeringa_lee2736 days ago688

reply all(3)I'll reply

  • PHP中文网

    PHP中文网2017-04-22 08:58:35

    The following content is from a colleague’s summary, posted and shared:
    Memcached
    Advantages of Memcached:
    Memcached can take advantage of multi-core, and the throughput of a single instance is extremely high, reaching hundreds of thousands of QPS (depending on the byte size of key and value and the performance of the server hardware, the peak QPS in daily environment is about 4-6w). Suitable for maximum carrying capacity.
    Supports direct configuration as session handle.
    Few pitfalls.
    Limitations of Memcached:
    It only supports simple key/value data structures, unlike Redis which can support rich data types.
    It cannot be persisted, the data cannot be backed up, it can only be used for caching, and all data will be lost after restarting.
    Data synchronization cannot be performed, and data in MC cannot be migrated to other MC instances.
    Memcached memory allocation uses the Slab Allocation mechanism to manage memory. Large differences in value size distribution will cause memory utilization to decrease, and may lead to problems such as kicking out even when utilization is low. Users need to pay attention to value design.

    Redis
    Advantages of Redis:
    Supports a variety of data structures, such as string (string), list (double linked list), dict (hash table), set (set), zset (sorted set), hyperloglog (cardinality estimation)
    Supports persistence operations, and can persist AOF and RDB data to disk for data backup or data recovery operations, which is a better way to prevent data loss.
    Supports data replication through Replication. Through the master-slave mechanism, real-time synchronous replication of data can be performed. It supports multi-level replication and incremental replication. The master-slave mechanism is an important means for Redis to perform HA.
    Single-threaded request, all commands are executed serially, and there is no need to consider data consistency issues in concurrent situations.
    Supports pub/sub message subscription mechanism, which can be used for message subscription and notification.
    It supports simple transaction requirements, but there are few use cases in the industry and it is not mature.

    Limitations of Redis:
    Redis can only use a single thread, and its performance is limited by CPU performance. Therefore, a single instance CPU can reach a maximum of 5-6w QPS per second (depending on the data structure, data size and server hardware performance. The peak QPS in daily environment is about 1-2w. about).
    It supports simple transaction requirements, but there are few usage scenarios in the industry and it is immature, which has both advantages and disadvantages.
    Redis consumes more memory on string types. You can use dict (hash table) to compress storage to reduce memory consumption.

    :) The following is my personal addition
    Both Mc and Redis are Key-Value types, which are not suitable for establishing relationships between different data sets, nor are they suitable for query searches. For example, the matching operation of redis keys pattern is a disaster for the performance of redis.

    Mogodb
    mogodb is a document database. Let me first explain the document database, which can store data of xml, json, and bson types. These data are self-describing and present a hierarchical tree-like data structure. Redis can use hash to store simple relational data.
    mogodb stores json format data.
    Suitable scenarios: event recording, content management or blogging platforms, such as comment systems.

    nosq currently has many products, and the architect’s choice is mainly driven by the following two factors:
    1) Suitable for application usage scenarios. For example, the comment system is more suitable to use mogodb, and mc can also be implemented (the application converts the data into json and saves it, but it is inconvenient to update some data)
    2) The team develops technologies that are familiar to them. For example, a team has been using mc, so it is limited to choose mc instead of redis.
    There are also medium to serious situations where the development team has been using mogodb and continues to choose mogodb in scenarios suitable for kv nosq.

    A book recommended to everyone: <NoSQL Essence>

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-22 08:58:35

    http://segmentfault.net/q/1010000002572713

    reply
    0
  • 黄舟

    黄舟2017-04-22 08:58:35

    redis and memcache are two caching mechanisms, mainly used to reduce database pressure and improve access speed. Redis can save the cache to the hard disk, and restart the computer to continue calling it. It also has many functions that memcache does not have. Memcache is simply cached in memory, with a single function and high efficiency. As for mongoDB, this is just a database

    reply
    0
  • Cancelreply