System Design Concepts -Caching & Caching Techniques
Hello Readers …👋,
Today let’s look at following topics of Caching. Hope you all like it 😀,
👉Cache
👉Levels of Cache
👉Caching Conditions
👉Types of Caching
👉Why Cashing
👉Advantages of Cashing
👉Disadvantages of Cashing
Cache
A Cache is a software or hardware component aimed at storing data so that future requests for the same data can be served faster.
The Caching is the process or method of storing copies of files or data in a (temporary storage )Cache .Caching is typically used to track frequent responses to a user’s queries.
It can also be used to store the results of long arithmetic operations. Caches store data in a separate location from the main data source, making data access faster. Like load balancers, caching can be used at various points in the system.
The cache generally contains recently accessed data. This is because recently requested data may be queried many times. Therefore, in such scenarios, caching should be used to minimize the process of retrieving data from the database.
Levels of Cache
- Client Side Cache
In client side cache Eliminating the need for clients to make server-side requests.
Once the browser requests data from the server, it stores it in the folder created by the browser. The next time you open a web page, it will not call the server to get the data, but extract the data from the browser cache folder.
- Server side Cache
Once a request is made to the user, the data is stored on the server. The next time the user makes a request, it only needs to retrieve the saved data from the server without extracting data from the database, so as to save time.
The server does not necessarily need to access the database to retrieve the data. You can also set a cache between the two components.
Caching conditions
Cache hit : If the requested data is found in the cache, it is called a cache hit.
- Suppose the copy of the requested web page (https://www.edgemesh.com/how-it-works) is stored in a cache. In that case, it results in a cache hit response, and the asset contained in the cache is delivered to the user.
Cache miss : If the requested information cannot be found in the cache, the system will be adversely affected. This is called a cache miss.
- If there’s no copy of the requested web page (https://www.edgemesh.com/how-it-works) found in the cache, it will result in a cache miss response — and the browser will have to make a new request from the main server.
To improve performance, we need to increase the number of hits and decrease the miss rate.
Data can become stale if the primary data source is updated and the cache is not updated. If stale data is not a problem for your system.
Write through and write back cache
Write back Cache
Database resources takes time to synchronize and the number of connection of a database is limited .Assume you have a database if you need more than 200 (connections) writes to this database then the front end write to the cache. Then cache processor act as a middle between cache and the database. The cache processor read from the cache and write to the database.
Get Kumuthini Ashokkumar’s stories in your inbox
Join Medium for free to get updates from this writer.
Cache Processor synchronize the cache and the database .Need to be very careful while Dealing with distribute caching server .
This mode has fast data write speed but data will be lost if a power failure occurs before the updated data is written to the storage.
Write through Cache
The Data simultaneously writes to cache and database(written to the main memory through the cache immediately).this mode is easy for operation but is slow in data writing because data has to be written to both the cache and the storage.
Types of Caching
- Web Caching (Browser/Proxy/Gateway)
- Data Caching
- Application/Output Caching
- Distributed Caching
Why Caching?
To efficiently reuse previously retrieved or computed data.
To allows developers to achieve performance improvements
To avoid making new requests or reprocessing data every time
Caches are widely used in most of the high volume applications to:
🤨Reduce Latency
🤨Increase Capacity
🤨Improve App Availability
Advantages of Cashing
👍It’s speed up the system.
- Speedup application
👍It’s improve system latency.
👍Reducing network demands
- Can support more load.
👍Improve performance
- System loads faster/better responsiveness
👍Improve the time complexity of the algorithm
- Avoid repeating the same complex calculations over and over again.
Disadvantages of Cashing
👎Stale Data
👎Overhead
👎Complexity
Final Thoughts 🤙
Give your response and stay connected for more 🙌
There are more to come 👉
I hope you liked the article 👍
Thanks for the reading 🙏










