Coder Social home page Coder Social logo

156420591 / caching-interview-questions Goto Github PK

View Code? Open in Web Editor NEW

This project forked from devinterview-io/caching-interview-questions

0.0 0.0 0.0 3 KB

🟣 Caching Interview Questions Answered to help you get ready for your next Design Patterns & System Architecture interview.

caching-interview-questions's Introduction

Top 18 Caching interview questions and answers in 2021.

You can check all 18 Caching interview questions here πŸ‘‰ https://devinterview.io/design/caching-interview-questions


πŸ”Ή 1. What is Caching?

Answer:

In computing, a cache is a high-speed data storage layer which stores a subset of data, typically transient in nature, so that future requests for that data are served up faster than is possible by accessing the data’s primary storage location. Caching allows you to efficiently reuse previously retrieved or computed data.

Source:Β medium.comΒ  Β 


πŸ”Ή 2. Is Redis just a cache?

Answer:

Like a cache Redis offers:

  • in memory key-value storage

But unlike a cash Redis:

  • Supports multiple datatypes (strings, hashes, lists, sets, sorted sets, bitmaps, and hyperloglogs)
  • It provides an ability to store cache data into physical storage (if needed).
  • Supports pub-sub model
  • Redis cache provides replication for high availability (master/slave)
  • Supports ultra-fast lua-scripts. Its execution time equals to C commands execution.
  • Can be shared across multiple instances of the application (instead of in-memory cache for each app instance)
Source:Β stackoverflow.comΒ  Β 


πŸ”Ή 3. What is Resultset Caching?

Answer:

Resultset caching is storing the results of a database query along with the query in the application. Every time a web page generates a query, the applications checks whether the results are already cached, and if they are, pulls them from an in-memory data set instead. The application still has to render the page.

Source:Β stackoverflow.comΒ  Β 


πŸ”Ή 4. What is Cache Invalidation?

Answer:

There are only two hard things in Computer Science: cache invalidation and naming things.

– Phil Karlton

HTTP caching is a solution for improving the performance of your web application. For lower load on the application and fastest response time, you want to cache content for a long period (TTL). But at the same time, you want your clients to see fresh (validate the freshness) content as soon as there is an update.

Cache invalidation gives you the best of both worlds: you can have very long TTLs, so when content changes little, it can be served from the cache because no requests to your application are required. At the same time, when data does change, that change is reflected without delay in the web representations.

Source:Β foshttpcache.readthedocs.ioΒ  Β 


πŸ”Ή 5. What usually should be cached?

Answer:

The results for the following processes are good candidates for caching:

  • Long-running queries on databases,
  • high-latency network requests (for external APIs),
  • computation-intensive processing
Source:Β www.eximiaco.techΒ  Β 


πŸ”Ή 6. Name some Cache Writing Strategies

Answer:

There are two common strategies to write data in a cache:

  1. Pre-caching data, for small pieces of data, usually during the application initialization, before any request.
  2. On-demand, checking first if the requested data is in the cache (if the data is found, it is called a cache hit), using it, improving the performance of the application. Whenever the requested data has not been written to the cache (cache miss), the application will need to retrieve it from the slower source, then writing the results in the cache, thus saving time on subsequent requests for the same data.
Source:Β www.eximiaco.techΒ  Β 


πŸ”Ή 7. What are some alternatives to Cache Invalidation?

πŸ‘‰πŸΌ Check all 18 answers


πŸ”Ή 8. Name some Cache Invalidation methods

πŸ‘‰πŸΌ Check all 18 answers


πŸ”Ή 9. Compare caching at Business Layer vs Caching at Data Layer

πŸ‘‰πŸΌ Check all 18 answers


πŸ”Ή 10. What are Cache Replacement (or Eviction Policy) algorithms?

πŸ‘‰πŸΌ Check all 18 answers


πŸ”Ή 11. What are some disadvantages of Cache Invalidation?

πŸ‘‰πŸΌ Check all 18 answers


πŸ”Ή 12. Why is Cache Invalidation considered difficult?

πŸ‘‰πŸΌ Check all 18 answers


πŸ”Ή 13. What is the difference between Cache replacement vs Cache invalidation?

πŸ‘‰πŸΌ Check all 18 answers


πŸ”Ή 14. Explain what is Cache Stampede

πŸ‘‰πŸΌ Check all 18 answers


πŸ”Ή 15. When to use LRU vs LFU Cache Replacement algorithms?

πŸ‘‰πŸΌ Check all 18 answers



Thanks πŸ™Œ for reading and good luck on your next tech interview!
Explore 3800+ dev interview question here πŸ‘‰ Devinterview.io

caching-interview-questions's People

Contributors

devinterview-io avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.