Lädt...


🔧 Caching — An overview


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

In simple terms, caching means storing the frequently accessed data in a storage where one can quickly retrieve it without the querying the source of truth i.e. the database. This storage is generally a temporary storage. Caching helps in improving the performance of an application by loading the data somewhere near to the application so the time taken in querying the db is reduced and also the number of times a data source is accessed is also reduced.

Applications can respond to the user requests more quickly improving the overall user experience. It also helps in reducing the load on the database since the data is now being accessed from the cache and not the db. One thing to note here is, Caching is suitable for frequently accessed data.

We all know CDN servers, DNS servers, Redis cache and Apache Ignite are some of the most commonly used cache in today’s world. I have already talked about CDN and DNS in my previous posts in case you want to read.

Let’s get an overview again:

CDN(Content Delivery Network) caches the static content and serves them to the users located in the nearby region.

DNS(Domain Name System) can cache the IPs of the servers and avoid the long path from the client’s IP to the authoritative server.

Redis and Apache Ignite are the caches mostly used as databases. Redis follows a Master-slave architecture whereas Ignite follows a distributed data structure.

There are many types of caching some of which are:

Client caching
Distributed caching
Database caching
Application caching

Let’s understand them one by one with the help of examples:

DISTRIBUTED CACHING

  1. A type of caching that involves storing data across multiple servers/nodes in a network.
  2. A perfect example for this is Apache Ignite.
  3. It has 2 caching modes: PARTITIONED and REPLICATION.
  4. In case of partitioned mode, the data is stored in chunks across multiple servers so if you have 100 units of data and 3 servers…30:30:40 can be the ratio of their storage.
  5. In case of replication mode, the data is stores as a whole across all the servers so if you have 100 units of data and 3 servers… each one of them would store all 100 units.
  6. This type of caching is useful when the application requires high availability and scalability. You can always add more nodes in order to scale and also in case a node goes down, the remaining nodes can handle the user requests.
  7. However, distributed caching trades of consistency in order to achieve high availability.
  8. Read about CAP Theorem and you’ll get a better clarity of why distributed caching follows an eventual consistency pattern.

DATABASE CACHING

  1. Database caching involves storing frequently accessed data in-memory rather than fetching it from the primary database every time, which reduces database load and improves overall performance.
  2. By routing the requests to the cache, you can achieve a much lower latency and also reduce the load on the database which includes querying it every time a request comes in.
  3. Instead of querying the database for every request, your application can first check the cache. If the data is found(cache hit), the request is served from the cache. If not found(cache miss), the request is sent to the database. Now this request can be stored in cache for future queries.
  4. For example, a user requests his/her information for the first time on a server. This request is served directly from the database. With caching, now the requested data is stored closer to the client after the first request, now for every similar request it would be served from the cache instead of your primary db.
  5. Caching solutions like Redis comes into play here.

CLIENT CACHING

  1. This type of caching involves storing data directly on the client device be it a web browser or a mobile phone.
  2. It becomes useful for applications that frequently access client’s locally stored information.
  3. Obviously, the application’s performance improves since now the number of requests to the server has been reduced that also leads to less data being travelled over the network.
  4. A perfect example for the same is Password storage in Mobile applications. Applications that ask you to enter a password to log into them, they might offer you to save the password on your device with a message like: “Don’t worry, this will be saved locally on your device.”
  5. Once you give your consent, the password gets stored locally on your device in some encrypted format and the next time you log in, the password field gets automatically populated.

APPLICATION CACHING

  1. Here the caching is done within the scope of application.
  2. API responses, User serssions can be cached and served to the user requests.
  3. Do not confuse it with database caching. They tend to be similar but are different when it comes to what is being cached.
  4. Application caching can cache api responses whereas database caching can cache query results.
  5. Anything at the application level can be cached using application caching be it an api response, a token or some computed value.
  6. Application cache lies closer to the application whereas database cache lies closer to the database.
  7. For example, let’s say you have an e-commerce platform. When a user logs in, his/her user session can be stored in the application’s in memory cache and now this session dadta can be served quickly without the need to go to the database.

These are some of the caching techniques. I have kept this post short and brief as I wasn’t feeling quite well but had to keep the streak of posting on weekends alive. Will come with better and detailed posts in future.

If you liked this post do consider liking it and you can also share and follow me for more such content :).

...

🔧 Best Redis Caching Strategy in Laravel: A Guide to Fast and Efficient Caching


📈 27.97 Punkte
🔧 Programmierung

🔧 Caching — An overview


📈 24.12 Punkte
🔧 Programmierung

🔧 Crawling December: HTTP caching


📈 13.98 Punkte
🔧 Programmierung

📰 Make Python Faster by Caching Functions: Memoization


📈 13.98 Punkte
🔧 AI Nachrichten

📰 Microsoft Details Disk Caching in Microsoft Edge


📈 13.98 Punkte
📰 IT Security Nachrichten

🔧 Caching & Memoization with state variables


📈 13.98 Punkte
🔧 Programmierung

🔧 Introducing encache: A Powerful Caching Library for Go


📈 13.98 Punkte
🔧 Programmierung

🔧 (SQL Query) Caching vs Indexing in Express.js


📈 13.98 Punkte
🔧 Programmierung

📰 Need for Speed: Streamlit vs Functool Caching


📈 13.98 Punkte
🔧 AI Nachrichten

🐧 Local apt-caching server for specific package list


📈 13.98 Punkte
🐧 Linux Tipps

📰 Popular RADIUS sever exploitable with TLS session caching


📈 13.98 Punkte
📰 IT Security Nachrichten

🔧 Supercharge Your Spring Boot App: Master Distributed Caching for Lightning-Fast Performance


📈 13.98 Punkte
🔧 Programmierung

📰 Improved Caching Produces a 5000x Performance Boost on Streamlit Dashboards


📈 13.98 Punkte
🔧 AI Nachrichten

📰 Azure HPC Cache: Neue Caching-Option, reduzierte Preise und mehr


📈 13.98 Punkte
📰 IT Nachrichten

🔧 Multi-Layered Caching with Decorators in Elixir: Optimizing Performance and Scalability


📈 13.98 Punkte
🔧 Programmierung

🔧 Basics of Caching


📈 13.98 Punkte
🔧 Programmierung

🔧 Optimizing Spring Boot Applications with Redis Caching


📈 13.98 Punkte
🔧 Programmierung

🕵️ Microsoft IIS 4.0 ASP Caching information disclosure


📈 13.98 Punkte
🕵️ Sicherheitslücken

🔧 🌟 Mastering Caching in JavaScript for Optimizing Performance 🚀


📈 13.98 Punkte
🔧 Programmierung

📰 CERT-Bund warnt vor Squid Caching Proxy-Schwachstellen


📈 13.98 Punkte
📰 IT Nachrichten

🐧 Caching DNS using Dnsmasq


📈 13.98 Punkte
🐧 Linux Tipps

🔧 Mastering Distributed Caching on AWS: Strategies, Services, and Best Practices


📈 13.98 Punkte
🔧 Programmierung

🔧 Why You Should Use Caching - Improve User Experience and Reduce Costs


📈 13.98 Punkte
🔧 Programmierung

🔧 That way to build High-Performance APIs in .NET - Part 2: Caching


📈 13.98 Punkte
🔧 Programmierung

📰 Need for Speed: Streamlit vs Functool Caching


📈 13.98 Punkte
🔧 AI Nachrichten

📰 StoreMI eingestellt: AMD entwickelt neue Caching-Software


📈 13.98 Punkte
📰 IT Nachrichten

📰 Intermediate CA Caching Could Be Used to Fingerprint Firefox Users


📈 13.98 Punkte
📰 IT Security Nachrichten

🔧 Docker Layer Caching Explained: Tips to Improve Build Times


📈 13.98 Punkte
🔧 Programmierung

🎥 Ab)using the Microsoft Identity Platform: ExploringAzure AD Token Caching


📈 13.98 Punkte
🎥 IT Security Video

🔧 Caching at DEV


📈 13.98 Punkte
🔧 Programmierung

🔧 Mind Boggling Speed when Caching with Momento and Rust


📈 13.98 Punkte
🔧 Programmierung

🔧 Caching vs Content Delivery Networks – What's the Difference?


📈 13.98 Punkte
🔧 Programmierung

📰 RAGCache: Optimizing Retrieval-Augmented Generation with Dynamic Caching


📈 13.98 Punkte
🔧 AI Nachrichten

matomo