Tair and Redis caching technology

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/cuidiwhere/article/details/102764336

The former in mind: when the image cache before working with is Tair. Recently seen many blog about Redis cache. So in the Internet to collect some information, the following is finishing reading pen.

1. Why use a cache?

why? Due to the high cost of time to directly access the database, using cache can reduce the number of database access, to enhance the response time of the program. While reducing pressure data

when? When using the cache? Data does not change frequently; or read from the source data can be time-consuming to put the cache, for example:

case 1: program several times to access the database, but the results are the same, the query results in the cache;

case 2: the results of database access to be very complex and time-consuming calculations, the results in the cache;

case 3: each page on the site needs user id information on the cache.

2. RDB drawbacks

The following is an excerpt from large data _ Tencent large-scale web system data cache design

Table 1. Single small amount of data: MySql single table of data in the number of control 2000w bar (20 million)

2. TPS too small: usually, MySql only the Transaction Per Second 1500

3. Response time: Normally, MySql response time is less than 10ms,

3.   Large web site challenge

Common daily PV ten million (200 million) of large-scale web sites challenge:

Each PV (page view)  to read and write the database generated amount may be exceeded several times, in this case, all data read and write requests daily amount may be far beyond the processing capability of the relational data, let alone in peak traffic under the circumstances; while in possession of hundreds of millions of pieces of data, 1w TPS when the response time should be less than 10ms, which is almost a relationship of any type of data can not be done. So how does this solve the problem? The most simple and effective way of course is to cache!

One day has 24 * 3600 = 2,073,600 ~ 2 million seconds; 

4. common type of caching

1. Local cache: either local memory or disk, its speed, low cost, highly effective in some cases. But not for load-balancing clustering architecture web system

2. Database Cache: mainly refers to the database query cache, most of the database will always provide. The basic principle is to do with the hash value of the query key, the result set caching; if good use, you can query the database efficiency greatly improved!

3. The client cache: a browser cookie, browser local cache, html5 cache

4. Distributed Cache: The purpose of existence is distributed cache to provide TPS and scalability higher than the RDB, but also to help you bear the pain of data synchronization; good distributed cache system will be familiar Memcached, Redis , Ali Tair contrast relational database and cache memory, which is the gap in reading and writing performance is enormous;. memcached single node may have done more than 15w TPS, Redis, google is also a lot of money levelDB performance, after large-scale clustering, performance may be higher! Therefore, in the case of technical and business are acceptable, we can try to put pressure transferred from the database to read and write to the cache in order to protect the seemingly strong, in fact, very fragile relational database.

5. Ali Tair cache

Tair is to provide fast access memory (MDB engine) / persistence (LDB engine) storage services, based on high-performance, high-availability distributed cluster architecture, to meet the requirements of high performance and capacity to read and write elastically stretchable business needs.

Tair support MDB, RDB and LDB three products, may be suitable for a variety of common storage scenarios.

  • MDB belongs memory products, kv and support structure hashMap class, the best performance, but does not support persistent storage; bottom package MDB engine is an engine memcache
  • RDB List.Set.Zset support complex data structures and the like, followed by performance, and may provide persistent storage buffer modes; RDB engine is redis
  • LDB belong lasting product, which supports kv and hashmap class structure, performance, slightly lower than the first two, but persistence highest reliability. Ldb is google levelDB engine

Ali, a senior technical experts: how to keep the system stable at 11 trillion dual-flow?

6. Redis

1. the Redis data types, data structures and code example

2. The  same is distributed cache, why Redis superior?

 

7. Tair, Redis, Memcached Performance Comparison Test

This paper mainly introduced Memcached and Redis Taobao open comparison test Tair distributed storage, since each different application scenarios, and each product can be configured many parameters, involving caching policy, distribution algorithm, serialization, data compression techniques, communication , concurrency, timeout, and many other factors, will affect the test results , there is a simple performance comparison a lot of limitations and unreasonable, it can not serve as any basis for this assessment purposes, to deepen the understanding of the respective products.

Reference material

1. Tencent large data _ large-scale web system data cache design

2.  Ali Tair github official homepage

3.  Tair, the Redis, the Memcached Performance Comparison Test

Guess you like

Origin blog.csdn.net/cuidiwhere/article/details/102764336