System Design | Distributed Cache | LRU Implementation | Systems design interview | Coding

  Рет қаралды 18,824

The Tech Granth

The Tech Granth

Күн бұрын

This videos answers your question, How do we design a distributed cache like redis or memcache?
Distributed cache system like redis or memcache is very helpful in application dealing with large data which is expecting a response from DB very fast. Since data is returned from RAM, cost of IO is very less. In this grokking the system design interview question, video we will learn how to design a caching system like redis. This system design tutorial will guide you with basics and high level design about what is distributed caching and how you can design it.
Redis Distributed cache system design is a commonly asked system design interview question. Most of the questions are based around the consistent hashing,lru,cache eviction policy cache write policy etc. and in the end interviewer might ask you to implement lru.
All these things are covered as part of this video.
Here I have explained about these things :
1) Introduction to Caching
2) Features and Specs of distributed cache
3) Cache Eviction policies
4) Cache Access/write Pattern
5) Scalability
6) Availability
7) Consistent Hashing
8) LRU(least recently used) Implementation using java
#distributedcache #thetechgranth #systemdesign
you can buy us a coffee at : www.buymeacoff...
system design(HLD & LLD): • System Design | Distri...
DS for beginners: • Arrays Data Structures...
leetcode solutions: • Leetcode 84 | Largest ...
github: github.com/The...
facebook group : / 741317603336313
twitter: / granthtech

Пікірлер: 30
@Siddharthnawani
@Siddharthnawani 3 жыл бұрын
Nice. Keep up the good work.. i think there is a slight issue in your LRU code, i think you have misplace a bracket, the correct implementation would look like : private void updateCache(int val){ if(!hSet.contains(val)){ if(q.size()==cacheSize){ int last = q.removeLast(); hSet.remove(last); } } else{ q.removeLast(); } q.push(val); hSet.add(val); }
@neeranchalgupta1644
@neeranchalgupta1644 2 жыл бұрын
yes right
@karthik3333ful
@karthik3333ful 2 жыл бұрын
This part of code doesn't seem right else { q.removeLast(); } Instead this is required to be used else { // value is present in the hashSet, so remove element from its current index in linked list in order to add that to the end q.removeLast(val); }
@nipulsindwani117
@nipulsindwani117 3 жыл бұрын
basically we have a hashing mechanism for mapping any value to be stored, suppose we have 10 servers to store the cache, and we want to to store some value 17, then we will apply hashing function (modulo here ) to map the value 17 to 7. After doing the cache value will be stored at this server, and when have some other value which comes to same server after mapping (say 27) then we will store it in the linked list, corresponding to number 7. and manipulate the linked list for getting the least recently used value. It was good until now, but in case some server goes down, then we will have lesser number of servers and same kind of value will be looked in for different servers. This is resolved by consistent hashing, which is a mechanism for making a circular arrangement, and incase some server goes down then its request will be moved to immidiate next value (server number here).
@GauravSharma-wb9se
@GauravSharma-wb9se 2 жыл бұрын
I think we can use singly Linked List as well by taking 2 pointers i.e. head & tail.....we can add element to the the tail and remove from the head.
@priytoshtripathi8000
@priytoshtripathi8000 Жыл бұрын
The problem comes when you need to retrieve an element from some mid portion area of the list and remove and connect it to the end of the list. That's why doubly linked list is used.
@rahulsrivastava1040
@rahulsrivastava1040 Жыл бұрын
Such a gold Mine
@GauravKawatrakir
@GauravKawatrakir 3 жыл бұрын
Better to write article/blog as well. So, it's easy to understand more.
@TheTechGranth
@TheTechGranth 3 жыл бұрын
Can you please let me know of the part, which is not clear, so that I can help with it.
@GauravKawatrakir
@GauravKawatrakir 3 жыл бұрын
@@TheTechGranth I mean if you write the article on the same. It's become better understandable.
@TheTechGranth
@TheTechGranth 3 жыл бұрын
@@GauravKawatrakir ok, will try that. Thanks for the suggestion :)
@GameProgrammer79
@GameProgrammer79 2 жыл бұрын
Consistent hashing was not clear as well as you didn't touch upon availability. I came here looking for redis cluster with replication using containers.. what got me listen till the end was curiosity and how bad it could be.. well it was not all that bad. Just few bits and pieces needs to improve. Pls read on earliest distributed system such as architecture used for CDN .. one important factor is distributed transactions e.g raft and consistency when designing such a cache. Usually it is a multi node mult partition with replication and often geographically distributed. Anyways it is a interesting topic.
@TheTechGranth
@TheTechGranth 2 жыл бұрын
Do check out other videos on HLD and LLD and let me know your views 🙂 Do like and subscribe and share with others 🙂
@subee128
@subee128 Ай бұрын
Thanks
@rameshbabuy9254
@rameshbabuy9254 3 жыл бұрын
keep going excellent work
@TheTechGranth
@TheTechGranth 3 жыл бұрын
Thank you. Do like, share and subscribe.
@artilamba1
@artilamba1 11 ай бұрын
nicely explained !!!
@nipulsindwani117
@nipulsindwani117 3 жыл бұрын
we have not talked much about the availability parameters of the distributed cache. One more suggestion, can we have a series on basic overview of technologies like, redis, rabbit mq, apache eureka, these are few to name, but as you said in the video that the candidate should be clear with the available tech stack. what do you say?
@TheTechGranth
@TheTechGranth 3 жыл бұрын
Yes would like to do that, some sort of POC on these, let's see. and regarding availabilty, like i mentioned in bookmyshow, each of the design videos are created keeping a specific problem in mind, BMS was about concurrency, this one is about scalability, so availability angle got missed but if you compare this with Amazon video for availability you can see that similar concepts will apply, plus here we are using zookeeper so that makes our job little easy from availability point of view as well.
@abhinavranjan3599
@abhinavranjan3599 Жыл бұрын
this type of implementation works for single system, explain how LRU will be implemented for distributed systems. you cannot use a double linked list for a 100 node cluster, where 100k users access it in parallel.
@GameProgrammer79
@GameProgrammer79 2 жыл бұрын
There was something to learn still there are many rooms for improvement
@debforu122
@debforu122 3 жыл бұрын
Please double check the LRU implementation. That's incorrect. If you remove q.removeLast(); even if queue size is not full, which means you are removing '27' and then q.push - which means 52 will be present twice in the linked list.
@TheTechGranth
@TheTechGranth 3 жыл бұрын
Yes, I have pinned a comment, the bracket position is wrong.
@SuperWhatusername
@SuperWhatusername 2 жыл бұрын
Thanks again :)
@TheTechGranth
@TheTechGranth Жыл бұрын
Recommended to watch at 1.25x or 1.5x as per convenience
@RahulSingh-my5wp
@RahulSingh-my5wp 2 жыл бұрын
Consistent Hashing could have been described in a better way.
@TheTechGranth
@TheTechGranth 2 жыл бұрын
Noted, will come up with a separate video on it 🙂
@deeptarungupta9906
@deeptarungupta9906 2 жыл бұрын
How is this distributed cache ? How is the cache of one node made available to another node ??
@rahulojha40
@rahulojha40 Жыл бұрын
I do have the same question, If data is not available at all the nodes how it is distributed ?
@ankursingh4115
@ankursingh4115 2 жыл бұрын
Consistent hashing is not this exactly
System Design Interview - Distributed Cache
34:34
System Design Interview
Рет қаралды 360 М.
王子原来是假正经#艾莎
00:39
在逃的公主
Рет қаралды 26 МЛН
Or is Harriet Quinn good? #cosplay#joker #Harriet Quinn
00:20
佐助与鸣人
Рет қаралды 48 МЛН
АЗАРТНИК 4 |СЕЗОН 1 Серия
40:47
Inter Production
Рет қаралды 1,2 МЛН
URL shortener system design | tinyurl system design | bitly system design
34:39
Tech Dummies Narendra L
Рет қаралды 463 М.
Redis system design | Distributed cache System design
34:10
Tech Dummies Narendra L
Рет қаралды 286 М.
System Design for Flash Sales: Sharding vs. Zookeeper vs. Redis vs. Kafka
30:49
Better Dev with Anubhav
Рет қаралды 3,7 М.
Whatsapp System Design | System Design| HLD | High Level Design
34:41
The Tech Granth
Рет қаралды 12 М.
Whatsapp System design or software architecture
27:40
Tech Dummies Narendra L
Рет қаралды 253 М.
Distributed Caching for System Design Interviews
7:04
ByteMonk
Рет қаралды 9 М.
System Design Interview - Top K Problem (Heavy Hitters)
36:18
System Design Interview
Рет қаралды 364 М.
Counting Youtube views/ad impressions exactly once
16:35
Vinayak Sangar
Рет қаралды 4,5 М.
王子原来是假正经#艾莎
00:39
在逃的公主
Рет қаралды 26 МЛН