Cache Usage considerations

Source: Internet
Author: User

Recently, many caching technologies have been used in projects, including local caching, remote centralized caching, and distributed caching. Some problems have also been found during Cache Usage. The overall situation is summarized as follows:

1. Pay attention to memory overflow when using local cache

Generally, the local cache is implemented by map, so it is easy to enter data in the map without limit, resulting in memory overflow. The best way is to use softreference to reference an object instead of a strongly referenced object.

2. Use local cache in a distributed environment. If the cache is the same type of data, such as the database configuration of the same table, you need to consider a synchronization measure, ensure that the data in each cluster is consistent.

In general, you need to regularly refresh the cache on each cluster machine. When refreshing the cache, be sure to lock the cache. In this case, the cache status between machines at a certain time is inconsistent.

3. For the remote centralized cache, you need to consider the remote call overhead and the serialization and deserialization overhead of the cached object.

The remote cache must be implemented by remotely calling the cache server. The remote call overhead is large, so the cache object settings should be reasonable to avoid multiple accesses to the cache information when an object is completed. Because of the serialization and deserialization overhead, the cache object should be as small as possible.

4. single point of failure (spof) must be considered for remote centralized caching. If the cache server is down, all access to the cache is invalid. The cache server that needs to be backed up.

5 distributed cache requires the cache object allocation algorithm. The allocation algorithm is very important and cache requests must be evenly distributed to each cache server. Especially when one cache machine is added or one is reduced, the hash consistency issue needs to be considered in the allocation algorithm.

6 distributed cache may also cause a write cache server to crash, which may affect cache access of 1/N.

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.