. Net data cache (1) Introduction,. net data cache Introduction
Today's business systems are becoming more complex, large portal websites are becoming more and more content, and the database data volume is growing. Therefore, the concept of "Big Data" has emerged. However, we all know that when the database data volume and Access frequency are too frequent, it will affect the overall system performance experience, especially for systems with high concurrency. Therefore, we use data caching to reduce the pressure on the database. To this end, the emergence of various cache technologies at the pace of time has dazzled us with these technologies. It is not to say that the most comprehensive and advanced functions are suitable for you. Let's take a look at the positioning of our system to determine which cache mechanism is suitable for our system. Of course, you can also define the cache interface to facilitate the replacement of the cache mechanism in the future. The following describes the concept, classification, and development trend of caching.
I. Concepts
A. Definitions
Data cache is a technology that stores data in the memory cache area.
B. Purpose
Generally, a large amount of data is stored in the database, and it is time-consuming for applications to access the database. If the data in the database is first cached in the cache, the system overhead can be reduced when the application needs the data, which is directly extracted from the cache.
C. Category
Local cache> cluster cache> distributed cache (data grid)
Reference: http://in.relation.to/2012/11/08/data-grid-why/Ii. Comparison of cache types
Cache type |
Local Cache |
Cluster Cache |
Distributed cache |
Storage location |
Application Server Memory |
Network Server Memory |
Network Server Memory |
Advantages |
Fast Access |
Each Server includes all the caches. |
Data Cache distribution. When the cache increases, you only need to operate on a single server. |
Disadvantages |
Limited Memory, not easy to expand |
You need to access all servers |
When a server (server cluster) is down or the network is abnormal, the cache of the server cannot be accessed. |
Suitable for system level |
The concurrency is small (<10), and the data volume is small (single table data <0.1 million ). |
Single business, large concurrency, and large data volume (about 200 concurrent users ). |
The business volume is complex and the concurrency is huge. |
Iii. Comparison of distributed cache frameworks
Name |
Couchbase |
Memcached |
Redis |
Description |
CouchDB uses JSON as its document format and is compatible with Memcached interfaces. |
The key-Value Pair storage method is implemented in the memory. The initial design is to implement Cache |
Key-value pairs are stored in the memory for databases, caches, and message proxies (because Redis is very performance-oriented, most designs require high performance and low latency) |
Data Model |
Document data (key-value pairs) |
Key-value pairs |
Key-value pairs (multiple data types and a rich set of operations, as well as configurable data expiration, eviction, and persistence) |
Official Website |
Www.couchbase.com |
Www.memcached.org |
Redis. io |
Initial Release |
2011 |
2003 |
2009 |
Current version |
3.0.3, December 3, March 2015 |
1.4.24, December April 2015 |
3.0.3, December 3, June 2015 |
License Agreement |
Open source (Apache version 2) |
Open source (BSD license) |
Open source (BSD 3-Clause, commercial license available) |
Trend chart |
Reference: db-engines.com/en/ |
Conclusion: The development of cache is actually the product of the previous type of evolution, so it can be compatible with the previous type. Which of the following solutions is the best and easiest? It depends on the architecture design requirements. There is no need to complicate simple things. However, to explain the cache, I will only explain Redis. Because it is the distributed cache with the highest usage currently. I will talk about how to use Redis later.