Website architecture-cache application (1) Concept

Source: Internet
Author: User

The topic of website cache is not new, but whether it can be used well is a learning. The same tool will do different things in the hands of different people. Here I will share with you some of my views and experiences on Cache applications in the website architecture. You may have some good ideas to add.

First, some basic concepts of cache.
1: The difference between cache and buffer. Program It can be understood as a primary cache for global data sharing. The buffer is a level-2 cache, which only shares data with some objects. The level-2 Cache mainly reduces the access pressure on the level-1 cache component and improves the cache access efficiency.
2: some basic attributes of the cache: hit rate, indicating the number of cache hits/total number of requests, which is one of the important quality indicators of the cache design; cache execution efficiency, such as get, insert, delete, etc.; capacity, that is, the maximum capacity of cache media; cost, that is, development cost, deployment cost, and hardware and software cost.
3: cache problems. The choice of storage media is usually left and right cache design. cache performance may often degrade if it is not hit.
2. Application scenarios of website cache:
1: The HTML of the entire page can be cached to Improve the access response capability;
2: cache partial page elements;
3: cache the results of complex data. For example, a query needs to combine multiple datasets and perform corresponding operations based on these datasets, even if each subset query has a cache, however, additional operations are required. In this case, you can consider caching the calculated results.
4: cache time-consuming queries, such as the query on the product list page.
5: Context-related user data, for example, the user enters the order success page from the Order details page, or click the order filling page when the detailed product is booked on the product list page, in this case, a large number of related values need to be transferred between the two pages. We can encapsulate all the values in a class and then communicate through the cache.
Third: factors that affect the cache hit rate.
1: Data is real-time. Each business system has corresponding requirements on its own data. Some data is very real-time, such as daily stock information. If cache is set for this situation, the cache hit rate is very low.
2: The cache granularity problem is generally because the cache span is too large, that is, when the key value contains too many conditions, the cache hit rate may be particularly low.
Fourth: How to Increase the cache hit rate:
1: Increase the storage medium capacity;
2: capture very popular data. You can use the real-time update cache method to balance the cache and real-time issues. For example, you can enable a background service to regularly update the cache.
3: Adjust the cache key value Algorithm To ensure that the cache key is fine-grained. Key-value is a good fine-grained example.
4: Adjust the cache expiration policy based on the business.

Fifth: How to Implement cache components:
1: The second-level Cache architecture is used, that is, the second-level cache is set on the Web server. The second-level cache here is the buffer mentioned above. It only shares data with the specific webserver, the second-level cache can be completed by using the cache component of the Microsoft enterprise database. Since the implementation of level-1 cache is usually a separate server, in order to reduce the pressure on the cache server, data is buffered on the webserver, the biggest benefit of reducing the load on the cache server is the cache access speed.
2: The primary cache is completed by a separate cache server. You can decide which cache scheme the cache server uses based on different scenarios. For ease of deployment, you can use the Microsoft enterprise database to complete the level-1 cache. If the server permits it, you can use memcached.
Advantages and disadvantages of using the Microsoft Enterprise Library on the Cache Server:
1: Advantages: development and deployment are very easy, and third-party software does not need to be installed;
2: disadvantages: You must develop your own client functions to achieve distributed processing. here we can use consistent hash algorithms. if the service is published in the form of WCF, the access efficiency is not optimal, compared with memcached.
Advantages and disadvantages of memcached:
1: advantage: the communication mode is higher than that of WCF;
2: disadvantages: third-party services are required, and memcached services must be installed on servers. This does not seem to be an important disadvantage.

Finally, paste the flowchart of website webpage data access for your reference.ArticleI will share the implementation scheme.

 

Author: Jiang min
Source: http://www.cnblogs.com/aspnet2008/

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.