Saturday, 22 December 2018

Cache concepts and cache techniques

The concept of the Cache memory has been around since long time. Cache memory is generally used to fill the performance gap between computing architecture and permanent storage. Permanent bulk storage cannot keep up with the performance requirements that of Compute/Application processing.

Cache can be hardware or software component that stores data in it so that future requests for the data can be served using data stored in cache instead of re-computing or fetching from permanent storage.

During read/write operations, if the requested data is found in a cache, It is called as Cache Hit. In case, requested data is not found in cache and needs recompute or fetch operation using permanent storage, it is called as Cache Miss.

As mentioned earlier, cache can be hardware or software component. Also cache can be used at various levels in computing architecture.  Below are some of the examples of hardware and software cache based on their usage at various levels.

Hardware Cache:

  • CPU Cache
  • GPU Cache
  • TLB (Translation Lookaside Buffer)
Software Cache:
  • Disk Cache
  • Web Cache
Caching Benefits:
  • Reduced latency of operations
  • Higher performance
  • Reduced IOPS to storage which results in lower SAN traffic and contention
  • Cost-effective use of high $/GB storage
Cache Techniques:

There are three main caching techniques that can be deployed. Each method comes with it's pros and cons.

  • Write-through
  • write-around
  • write-back
Write Through:
  • Write-through cache directs write I/O to cache and through to underlying permanent storage before confirming I/O completion to the host. This ensures data updates are safely stored.
  • Disadvantage with this technique is that the I/O experiences latency based on writing to permanent storage. 
  • Write-through cache is good for applications that write and then re-read data frequently as data is stored in cache and results in low read latency.
Image Credit: CodeAhoy

Write Around:
  • Write-around cache is a similar technique to write-through cache, but write I/O is written directly to permanent storage, bypassing the cache. 
  • This can reduce the cache being flooded with write I/O that will not subsequently be re-read. 
  • Disadvantage is that a read request for recently written data will create a “cache miss” and have to be read from slower bulk storage and experience higher latency.
Write Back:
  • Write-back cache is where write I/O is directed to cache and completion is immediately confirmed to the host. 
  • This results in low latency and high throughput for write-intensive applications, but there is data availability exposure risk because the only copy of the written data is in cache. 
  • Write-back cache is the best performer for mixed workloads as both read and write I/O have similar response time levels.
Image Credit: CodeAhoy

Relating above information in VMware virtualization, vSphere has features like vFRC, vSAN that uses cache mechanism. vFRC supports write-through or read caching whereas VMware vSAN uses Write back caching mechanism.

No comments:

Post a Comment

Popular Posts This Week