by BehindJava

What are the system design Specifications and Features of Cache

Home » interview » What are the system design Specifications and Features of Cache

These are the specifications and features of a Cache in System design.

Specifications:

  1. Size of Cache: Cache is graded as Level 1 (L1), Level 2 (L2) and Level 3 (L3): L1 is usually part of the CPU chip itself and is both the smallest and the fastest to access. Its size is often restricted to between 8 KB and 64 KB. L2 and L3 caches are bigger than L1.
  2. Queries per second: QPS is a measure of the amount of search data an information-retrieval system, such as a cache or a database, receives in one second.The term is used more broadly for any request–response system i.e., RPS.
  3. Cache Validity: You can control the freshness of your cached data by applying a time to live (TTL) or expiration to your cached keys. After the set time has passed, the key is deleted from the cache, and access to the origin data store is required along with reaching the updated data.
  4. Cache Hit Ratio: Cache hit ratio is a measurement of how many content requests a cache is able to fill successfully, compared to how many requests it receives. A content delivery network (CDN) provides a type of cache, and a high-performing CDN will have a high cache hit ratio.
  5. Cache Miss: A cache miss is an event in which a system or application makes a request to retrieve data from a cache, but that specific data is not currently in cache memory. Contrast this to a cache hit, in which the requested data is successfully retrieved from the cache. A cache miss requires the system or application to make a second attempt to locate the data, this time against the slower main database.
  6. TTL(Time to Live): Time to live (TTL) is the time that an object is stored in a caching system before it’s deleted or refreshed.

Features:

  1. Cache Access Pattern: Cache Access Pattern (CAP), is a policy that detects patterns, at the file and program context level, in the references issued to the buffer cache blocks. Precise identification is achieved as frequently and repeatedly access patterns are distinguished through the use of reference recency.
  2. Cache Eviction: Eviction refers to the process by which old, relatively unused, or excessively voluminous data can be dropped from the cache, allowing the cache to remain within a memory budget. Generally, applications that use the Second Level Cache should configure eviction, unless only a relatively small amount of reference data is cached.
  3. Availability: System must have multiple caches to be fail safe.
  4. Scalability and consistent Hashing: Consistent Hashing solves our problem when we want to dynamically add or remove servers. In the case of simple hashing, addition or removal of a server will impact all the M keys stored in the system. However, Consistent Hashing ensures that only M/N keys are affected where N is the number of servers.
    Consistent Hashing makes the distribution of the keys independent of the number of servers used by the system. Thus, we can scale up or down without impacting the overall system.