Large Web site architecture (3) cache

Source: Internet
Author: User

When it comes to caching, I think everyone is just as excited as I am when we encounter a performance bottleneck on the site, cache is a strong heart needle, but also an emergency mom, so in optimizing the performance of the site crown on the first law of the Hat, the year before we do Amoy application, encountered a performance bottleneck, a short period of time using cache emergency optimization, Give us a big optimization before winning a valuable time.

One: type of cache

To say how many kinds of cache, too much, such as browser caching, file caching, fragment caching, database caching, and so on, reasonable use of these caches can greatly improve the performance of the system, the use of bad will steal the chicken does not eclipse the rice, the server caused great pressure, so there is a principle of the use of caching problems.

Second: Reasonable use of the cache

1. Read and write less than 10:1 case, not suitable for caching, we use the purpose of caching is to share the database under the pressure and use of memory to speed up performance, if read or write almost, or never read, such dead data will cause the waste of memory resources.

2. Since it is a cache, it is doomed to its resources are limited, precious, it is doomed we must use its memory space reasonably, it is forced to let us clearly recognize the hot data, not easy to modify should be placed in the cache, vice versa.

3. A good place for large companies to do caching is in a "control" word, they will be dedicated to the cache a "caching system", when the system preload, but also acts as a memory database use, the metadata loaded into the cache system, such as "County", "classified information" and so on as preheating data.

Third: Distributed caching

Under normal circumstances, there will be two forms, the first is the mode of master-slave copying, the second is the pattern of fragmentation.

1: Master-slave copy mode

This mode had also used in the project, is a memory, multiple backup, when the data in one of the cached content has changed, will notify other machines in time to update or clear the cache, the disadvantage of this model is relatively easy to be subject to the memory limit of a single machine, The advantage is to use a heartbeat mechanism in time to replace with another cache machine, at that time we use 120G of large memory, benefiting from the project business scale limitations, otherwise when the machine memory is full when it is more embarrassing, so do a large website or use it cautiously, after all this is also we have done some to improve the performance of the attempt.

2: The pattern of fragmentation

This pattern is still heavily used in large Web sites, it is characterized by a large lump of data through a certain algorithm and configuration allocated to a number of machines in the cluster, if a cluster in a machine hangs, it does not matter, will only affect the data in the machine, the database will not cause a great impact. A typical application is that Memcache,memcache is a very simple, practical, efficient distributed caching architecture, in fact Memcache most worth mentioning is "the routing algorithm consistency hash" technology makes our memcache cluster can scale freely, But now there are a lot of nosql products, such as Redis,couchdb,mongodb and so on, so that we have more choices in the world.

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/web/Skills/

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.