- First of all, the Redis and memcached are all cached in memory, and the only difference is that Redis itself periodically writes some updated data to the disk or modifies it to the appended record file, and implements Master-slave master-slave synchronization on this basis.
- As far as performance is concerned, Redis is a high-performance Key-value memory database. Official Performance Test results: Set operation 110,000 times per second, get operation 81,000 times per second
- Redis itself supports a relatively large number of data types, including string, list, set (set), Zset (ordered collection).
- Redis data persistence is mainly a snapshot and aof log two durable ways, in practical applications, it is important to pay attention to the parameters of the profile snapshot, to prevent frequent dump.
- Memcachedis a high-performance distributed memory cache server, which can improve the speed and scalability of applications such as dynamic Web by caching database query results and reducing database access times.
- memcached features as a distributed cache server: &NBS P , &NB Sp
- protocol Simple
- Libvent-based event handling
- internal memory storage
- memcached distributed without communication
- MEMCA Ched the default support for the largest storage object is 1M. This value is determined by its memory allocation mechanism. (It uses the slab allocator mechanism to allocate and manage memory by default.)
- memcached set data is the default compressed
- Business scenario for memcached:
- A Dynamic Web page with very high site traffic. Because most data requests are read, memcached can effectively reduce the load on the database.
- assumes that the load on the database server is low but the CPU usage is very high, so that the computed results (computed objects) and the rendered page template (enderred templates) can be cached. The
- caches some files that are very small but frequently accessed.
- memcached can accept the maximum length of a key is 250 characters
- redis
- Redis as a high-performance Key-value database has the following characteristics
- diversification
- Persistence
li> master-Slave sync &N Bsp , &NB Sp
- Redis supports a wide variety of data types, typically five: String, Hash, L ist, Set, and Sorted set. Redis typically stores data in memory or is configured to use virtual memory. One of the most important features of Redis is that it can implement persistent data, which can be persisted in two ways: using an Rdb snapshot to keep the in-memory data written to disk, or logging each update with a aof log method like MySQL. The former performance is high, but may cause some degree of data loss; the latter is the opposite. Redis supports synchronizing data to multiple slave databases, a feature that is useful for improving read performance.
- A place of careful attention
- Memcached single Key-value size is limited, one value Max supports only 1MB, and Redis supports 512MB maximum
- Memcached is simply a memory cache that requires little reliability, and Redis prefers a memory database, so the reliability requirements are high
- In essence, memcached is just a single key-value memory cache, and Redis is a data structure memory database that supports five data types, so Redis has a simple cache and can handle some simpler logic, and it can also be used as a database
- The new version (3.0) of Redis refers to the cluster distributed, that is, the cluster itself balanced client requests, each node can communicate, can expand line, maintainability more powerful.
Redsi and memcached Difference summary