Caching in System Design — Part 1

Muhammad Nouman Ali
2 min readJan 22, 2024

--

Caching is the powerful technique in order to optimize the performance of your system.
When a client sends request to a server, server sends the response back to the client. It is how client/server model work. This is okay when traffic is low and there are not much of same requests. But what if client send same request again and again. In this scenario, you server response back every time for the same request it sends the response earlier. This will slow down the performance of your system. Here cache comes in to play the part.

Cache/Caching
Cache is the high-performing storage like layer, servers between your application and the actual source of your data. So when a client sends the request, it first checked in cache and if response for that request not present then it will be requested to the actual source and this response store in the cache for future requests.
So If client sends the same request after some time ( say after 2 min ) , its response will be present in the cache and sends back to the client.

Hit / Miss
When response of specific request present in the cache it is called Cache Hit and if response not present then it is called Cache Miss.
So for every new request, first time it will always Cache Miss.

You will be thinking, in case of hit/miss or storing response of request, wouldn’t the response will get out dated like think on every reload on social media you get the same posts.

Here comes the Cache Replacements Policies.
Cache Replacements Policies
1 — Least Recently Used
2 — Least Frequently Used
3 — First In, First Out
4 — Random Replacement

--

--

No responses yet