I'm going to talk about it. Large Web site Architecture series (3)--dead to say the cache

Source: Internet
Author: User
Tags browser cache

When it comes to caching, I think everyone is as excited as I am, and when we encounter site performance bottlenecks, the cache is a strong needle and an emergency mom Fulong, which optimizes the site

Performance of the Crown on the first law of the hat, we were in the year before the application of Amoy, encountered a performance bottleneck, a short period of time using cache emergency optimization, give us a big optimization before the

Valuable time.

One: type of cache

To say how many kinds of cache, too many, such as browser cache, file cache, fragment cache, database cache, etc., reasonable use of these caches can greatly improve system performance,

Use bad instead will steal chicken not eclipse put rice, to the server caused great pressure, so there is a cache of the use of the principle of the problem.

Second: Reasonable use of the cache

1. Read and write less than 10:1 cases, not suitable for the cache, we use the purpose of caching is to share the pressure of the database and use memory to speed up performance, if read and write almost, or

Never read it, so dead data can be wasted on memory resources.

2. Since it is a cache, it is destined that its resources are limited, valuable, it is destined to use its memory space reasonably, it is forced to let us clearly understand the hot data,

Not easy to modify should be placed in the cache, the contrary should not be put.

3. Big companies do a good job of caching in a "control" word, they will specifically for the cache a "cache system", when the system preload, but also act as a memory database

Use, the metadata is loaded into the cache system, such as "County city", "classified information" and so on as preheating data.

Three: Distributed cache

In general, there will be two forms, the first is the master-slave replication mode, the second is the Shard pattern.

1: Master-slave copy mode

This mode is also used in the project, that is, a memory, multiple backups, when the data in one of the cached content changes, will notify other machines to update the cache in time roost

Or clear, the disadvantage of this mode is relatively easy to be subject to the memory limit of a single machine, the advantage is to use the heartbeat mechanism in time to replace with another cache machine, at that time we use 120G

of large memory, due to the size of the project business constraints, or when the machine memory is full when it is more embarrassing, so do large sites or use it carefully, after all, this is what we have done

A number of attempts to improve performance.

2: Pattern of shards

This model is still widely used in large-scale Web sites, it is characterized by a large amount of data can be distributed through a number of algorithms and configurations to several machines in the cluster, if the cluster

One of the machines hung up, it doesn't matter, it will only affect the data in the machine, the database will not have a great impact. A typical application is that Memcache,memcache is a

A very simple, practical, efficient distributed cache architecture, in fact, memcache most noteworthy is "routing algorithm consistency hash" technology so that our memcache cluster can

Free to stretch, but now there are a lot of nosql products, such as Redis,couchdb,mongodb and so on, so we have more choices in this world.

Recently saw a lot of complaints in the garden, it's okay, if you feel wasted, welcome to Ctrip to try, only you can not reach the ability, not to give you pay.

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.