[Cache design] is the most basic multi-level cache suitable? How should I set it?

Source: Internet
Author: User
Recently, I want to provide a one-level caching mechanism for our system. But I always feel something is missing. Environment: server load balancer, master-slave separation, Redis single-host (multiple hosts can be used in the future) preliminary concept: {code ...} after accessing the Web application, the user sets the browser cache for it, and then sets the local... recently, I want to provide a one-level caching mechanism for our system. But I always feel something is missing.

Environment:
Server load balancer, master-slave separation, Redis single-host (multiple hosts can be used in the future)

Preliminary ideas:

Browser cache-local file cache-memory cache (Redis)-Db

After accessing a Web application, you can set browser cache and local file cache and memory cache.
After access by other users, I think the steps are as follows:

  1. Check whether browser cache exists

  2. Check whether the local machine has a file cache

  3. Memory cache

  4. Db

My problem is:

However, I think there is something missing in a specific step, or it is difficult to choose the (multi-level) cache expiration time.

In addition, is it worth comparing the local file cache {check expiration time, read (delete, generate) file} with a connection that directly jumps to the memory cache (Redis?

Therefore, I would like to ask if my basic Cache mechanism is appropriate or if there are any drawbacks that can be improved. thank you!

Reply content:

Recently, I want to provide a one-level caching mechanism for our system. But I always feel something is missing.

Environment:
Server load balancer, master-slave separation, Redis single-host (multiple hosts can be used in the future)

Preliminary ideas:

Browser cache-local file cache-memory cache (Redis)-Db

After accessing a Web application, you can set browser cache and local file cache and memory cache.
After access by other users, I think the steps are as follows:

  1. Check whether browser cache exists

  2. Check whether the local machine has a file cache

  3. Memory cache

  4. Db

My problem is:

However, I think there is something missing in a specific step, or it is difficult to choose the (multi-level) cache expiration time.

In addition, is it worth comparing the local file cache {check expiration time, read (delete, generate) file} with a connection that directly jumps to the memory cache (Redis?

Therefore, I would like to ask if my basic Cache mechanism is appropriate or if there are any drawbacks that can be improved. thank you!

  1. Multi-level caching can reduce system pressure and greatly reduce rt. However, the management of multi-level caching needs to be considered. this is also mentioned in the article, this is a problem that cannot be avoided by using multi-level caching. As for how to invalidate the multi-level cache, you can use a local timer to cut off the time and refresh the cache

  2. The file cache can actually be replaced with the local memory cache. it is also possible to design the file cache, but when the equivalent is large, the local disk I/O, i'm afraid I can't help but decide which efficiency is better with network overhead. I need to stress test it based on the actual situation.

  3. Multi-level cache provides more solutions: cache penetration and program robustness. when there is a problem with centralized cache, our applications can continue to run. some hotspot data is made into memory cache, you do not need to access the centralized cache to reduce the pressure on the centralized cache. Therefore, the file cache is better than the Redis centralized cache.

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.