When it comes to caching, I think everyone is as excited as I do. When we encounter a website performance bottleneck, caching is a powerful tool and an emergency mom Fu long to optimize the website.
In terms of performance, the first law of performance came to the fore. When we were doing Taobao applications the year before, we suffered a performance bottleneck. in a short period of time, we adopted the cache for urgent optimization, and we had to fight for it before the major optimization.
Valuable time.
There are too many cache types, such as browser cache, File Cache, segment cache, and database cache. Using these caches can greatly improve system performance,
If it is not easy to use, it will steal the chicken and lead to huge pressure on the server. Therefore, there is a cache usage principle problem.
1. When the read/write ratio is less than, it is not suitable for caching. The purpose of using the cache is to share the pressure on the database and use the memory to speed up the performance.
I have never read it at all. Such dead data will cause a waste of memory resources.
2. since it is a cache, it is doomed that its resources are limited and valuable, and it is doomed that we must make reasonable use of its memory space, it is forced to let us clearly understand the hot data,
If it is not easy to modify, it should be placed in the cache; otherwise, it should not be placed.
3. A good thing for large companies in caching is that they will create a "cache system" for caching. When the system is pre-loaded, it also acts as a memory database
Used to load the metadata into the cache system, such as "County and City" and "category information.
Generally, there are two forms. The first is the master-slave replication mode, and the second is the sharding mode.
1: master-slave replication Mode
This mode was also used in the project today. It is a copy of memory and multiple backups. When the data in one of the cache content changes, other machines will be notified in time for cache updates.
Or clear, the disadvantage of this mode is that it is relatively easy to be subject to the memory limit of a single machine, the advantage is to use the heartbeat mechanism to replace with another cache machine in time, at that time we use 120G
Large Memory, thanks to the project business scale restrictions, otherwise it will be awkward when the machine memory is full, so we should be cautious when using large websites. After all, this is what we did today.
To improve performance.
2: partition Mode
This mode is still widely used in large websites. It features that a large volume of data can be apportioned to several machines in the cluster through certain algorithms and configurations.
It doesn't matter if a machine crashes. It only affects the data on the machine and does not have a great impact on the database. A typical application is memcache, which is
This is a very simple, practical, and efficient distributed Cache architecture. In fact, the most important thing about memcache is that the "consistent hash of routing algorithms" technology enables our memcache cluster
Free scaling, but now there are a lot of nosql products, such as redis, couchdb, mongodb, etc. Let's have more options in this world.