Redis system design | Distributed cache System design

  Рет қаралды 283,433

Tech Dummies Narendra L

Tech Dummies Narendra L

Күн бұрын

This video explains how to design distributed cache system like Redis/Memcache
This is one of the famous Amazon interview question.
How to distribute nodes?
Answer: using consistent hashing.
I have already made a video on this topic • Amazon Interview quest...
Donate/Patreon: / techdummies
Apart from LRU you can use Countmin sketch.
to calculate frequency of key accessed use Countmin sketch
• Count min sketch | Eff...
----------------------------------------------------------------------------------------------------------------------------------------------------------
LRU Code by Varun Vats:
gist.github.com/VarunVats9/c2...

Пікірлер: 249
@shreyasahu481
@shreyasahu481 3 жыл бұрын
If you're aware of how caching works and LRU and came here curious about the design of how distributed caches work, start at 23:42 . And very well put content, as always :)
@NitishSarin
@NitishSarin 5 жыл бұрын
You are a Hero, man! These are all the topics that we actually need. And sadly find no decent tutorial videos online! Thanks.
@TechDummiesNarendraL
@TechDummiesNarendraL 5 жыл бұрын
Hey, Thanks :)
@priyakantpatel6866
@priyakantpatel6866 3 жыл бұрын
Given the time you were on the spot, my expectation was higher! I was more expecting HA & DR as well..! As usual, you are awesome.
@AbhishekGupta05
@AbhishekGupta05 5 жыл бұрын
Thanks for the video. I have a question. For ensuring availability, how about having a load balance which decides which server to hit. It would be more convenient design because only write operation need to be synced to both servers, whereas read operation can happen via any server. This would also ensure minimum latency for requests. Expecting your response
@thmoeboa
@thmoeboa 4 жыл бұрын
Thanks for this! Great content across your channel.. I feel stronger on system design :)
@rishitrastogi8103
@rishitrastogi8103 4 жыл бұрын
When you delete the head of the LRU linked list to make space in the cache, wouldn't you also need to invalidate its address stored in the hash table.
@amitchauhan7048
@amitchauhan7048 3 жыл бұрын
Yes. we will need to remove it from hash table as well. For this we already have the value that needs to be removed (on that node). We can pass that value through hash function and remove that value from the hash table.
@hasifkhan8197
@hasifkhan8197 5 жыл бұрын
The best thing i like in this course is your style of wearing the cap in presentation.
@pushpendrasingh1819
@pushpendrasingh1819 4 жыл бұрын
bhai koi style nhi h...... baal nhi h iss bhai k .. mera bhi same scene h and m bhi cap lagata hu
@achatterjee104
@achatterjee104 3 жыл бұрын
Thanks for the video tutorials, thats first :), but I still hv some questions/comments, may b i am wrong, but let me tell u that..plz correct me if i m wrong...1. Not clear - how ur design got impacted with the estimation that u made at first, how ur design could get changed in case of 5 request/sec tps 2. How a value in hastable results into constant time lookup in linked list 3. Only apart from the last part, all other areas are also applicable for monolithic system., so it seems like that distributed philosophy is needed to be adderessed more
@talivanov93
@talivanov93 4 жыл бұрын
Thanks for the explanation, helped a lot!
@pranaypatadiya
@pranaypatadiya 4 жыл бұрын
Thank you so much for giving a lot around thought process and guiding the though process while designing complete system around any concept/problem. Thank you. Your in detailed content be the saviour for me in lead interview. Thank you.
@ankita4priya
@ankita4priya 5 жыл бұрын
Nice explanation. Thanks for the awesome videos. :)
@michahubert1179
@michahubert1179 4 жыл бұрын
It misses very important part: how does LRU eviction work ? In your design we add to cache as many items as we want leading to out of memory. I think you shall have mentioned that LRUs are limited either by the number of elements or their total size. If adding a new element would exceed limit then we need to evict one element(*) and we pick this element from the front of linked list and based on it's key we remove entry from hash table and delete node in linked list. * - if w limit LRU by memory size we might keep removing elements till memory goes back below threshold.
@springtest540
@springtest540 5 жыл бұрын
Again Very nice Video.. thanks sir :)... waiting more videos like this....
@piyushyadav2279
@piyushyadav2279 3 жыл бұрын
thanks bro!! it was an awesome video, i was really searching for an good caching video!!, it was explanatory!!
@_sudipidus_
@_sudipidus_ 4 жыл бұрын
who else noticed 'cashing' in the beginning whiteboard ? Great content bro
@escalocity
@escalocity 2 жыл бұрын
Regarding log reconstruction, I suppose log data will be written to disk only after sufficient data is accumulated or a certain period has passed to reduce the disk access latency. If that is the case then how do you make sure data is not lost during that period?
@nishadkumar7322
@nishadkumar7322 4 жыл бұрын
Thanks a lot +Narendra. This is an invaluable video.
@ashishrane1352
@ashishrane1352 5 жыл бұрын
Really good video .. How are typically range queries handled? Firstly they condition may vary and also the range may vary? Most probably the same condition or range may never be used for a while? Do normally range queries get cached?
@ameyapatil1139
@ameyapatil1139 4 жыл бұрын
Brother your videos are fantastic. I just have a suggestion to use a better microphone for more clear recording. Thanks for this video.
@menglishu4328
@menglishu4328 4 жыл бұрын
How switching to master slave pattern solves the syncing issue between the replicas? If we are only writing to master, how does the slave get updated? By snapshot? That will still havé inconsistency right?
@piyushdeshmukh4706
@piyushdeshmukh4706 3 жыл бұрын
You accept writes at Master nodes, and let the replication log propogate to the secondary nodes. That is the basic Multi Leader replication. But but but, There seems to be multiple masters in the last explanation, in such a case even masters would need to sync up with themselves. If that sync is via network (which it ofc is), what is the point of using it in a caching system!! Better invalidate and then make DB queries.
@blackcatcaptain2022
@blackcatcaptain2022 5 жыл бұрын
29:17 snapshot + log replay. Normally restore from recent snapshot first, then replay the remaining log. All previous logs before the recent snapshot timestamp can be reclaimed.
@DenisG631
@DenisG631 5 жыл бұрын
but how does snapshotting and log replaying work if node is down for a long while and a new master has completely new snapshot and other log (log is cleared after snapshotting). Is the snapshot passed to the slave which just restarted or how does this happen. Otherwise, even though the node replays the log it still has stale data comparing to its peers
@jasonsui9029
@jasonsui9029 3 жыл бұрын
@@DenisG631 For sure, slave nodes or active-active nodes will have the sync-up periodically, if the server goes down, the next-chozen server will start the latest snapshot itself have(it may be earlier than the down server's snapshot), and replay all the logs since this new server's snapshot.
@abhishek041990
@abhishek041990 5 жыл бұрын
Very nicely explained. Could you come up with a video on 'Designing Distributed Scheduler' ?
@vitaliano01
@vitaliano01 3 жыл бұрын
Thank you for the AWESOME tutorial
@saikat2sls
@saikat2sls 3 жыл бұрын
I really didnt see any distributed cache system in most of the video... the title should be changed to working of cache.
@venkatadriganesan475
@venkatadriganesan475 3 ай бұрын
You need to check the big picture and assemble the puzzles here. He has spit the design into several parts.
@knight0856
@knight0856 4 жыл бұрын
One question Naren, on design, as we have event loop in place, suppose we have two requests put and get, so get will have to wait until put request completed and than event loop will read this. Doesn't this event loop be a multithreaded ?
@NitinPatel-ld5qd
@NitinPatel-ld5qd 4 жыл бұрын
Hi Narendra - great videos indeed, pls keep them coming! By the way how to do handle concurrency (writes) issues?
@NikashKumar
@NikashKumar 5 жыл бұрын
Great, can you make a video on "Design a Amazon locker system" and "Chicken nugget problem". I understand it takes a lot of work to make a video, and i appreciate your work a lot. It would be helpful if you can make a design interview video on locker system soon.
@rajkiran9093
@rajkiran9093 3 жыл бұрын
Hey can we discuss amazon locker
@contactnarita
@contactnarita 2 жыл бұрын
Liked your content. Partly the content is inspired (I don't mean copy paste here) by Cassandra architecture. Or in other words, we can always draw parallel (conceptually) with these distributed architecture frameworks. Thanks for raising my awareness.
@subhranshuchatterjee3940
@subhranshuchatterjee3940 5 жыл бұрын
I was asked a system design question. LinkedIn wants to Integrate with Dropbox. LinkedIn does not do business about document storage. However LinkedIn had 400 webservers and after integration with Dropbox, they do not want to scale up. Is it possible to make such integration without adding more servers?
@krishnamohanty1258
@krishnamohanty1258 5 жыл бұрын
hi. Can you make some video on how to handle heavy traffic ,loadbalancing ,zookeeper. how all these factors helps to increase response time
@RajKumarSingh-it5sn
@RajKumarSingh-it5sn 5 жыл бұрын
Great explanation
@bhatanand
@bhatanand 2 жыл бұрын
ARC is probably the best cache eviction algorithm as it takes care of both recency and number of hits. Its generally not seen in open source as IBM holds a patent for the algo.
@DebasisUntouchable
@DebasisUntouchable 4 жыл бұрын
RAM is blocking part, in event loop design RAM would still be blocking to the threads from the pool, ie. only one tread can access it. So how is it better from other designs? Is cache is shradded and duplicates are maintained?
@manaligadre7809
@manaligadre7809 5 жыл бұрын
Wow!! One video and you cleared thousands of doubts !!
@fermatslasttheorem6298
@fermatslasttheorem6298 2 жыл бұрын
Personally I don't think the hash table and linked list approach used here is good for an LRU caching data structure. Especially since with caching, you want fast access. The linked list approach described with the index positions requires O(n) access to loop through the linked list. You can use a hash table and linked list to have O(1) access by having the hash table keys mapped to each linked list node (instead of a key mapped to a chain of nodes). So if you have the table keys [1, 2, 3, 4, 5] and the linked list A B C D E, you could have the mapping [1: B, 2: A, 3: C, 4: E, 5: D]. The most recently accessed object is moved to the top of the linked list which is very simple to do for a double linked list (O(1) time). The key reference remains the same - only the node positions change. The point is as new data is added to the cache, the last node is deallocated if the limit is reached. Reading is O(1), moving to top is O(1), and deallocating is O(1).
@kevinmcdaniel8327
@kevinmcdaniel8327 3 жыл бұрын
Could you use a bitmap instead of a link list to determine the LRU faster?
@bipinsharmaregmi2212
@bipinsharmaregmi2212 5 жыл бұрын
Your channel is very helpful. Is it possible to make video on Traffic Light System Design because I have found this questions in many Big Tech Companies Interview. Appreciated for this video on Distributed caching and expecting more from you. You are almost like celebrity for us.
@TechDummiesNarendraL
@TechDummiesNarendraL 5 жыл бұрын
Thanks @Bipin, this means a lot.
@spk9434
@spk9434 5 жыл бұрын
Good one. Do we need to talk about the updates to distributed hash map ? like locking the buckets etc ?
@sushmitagoswami7320
@sushmitagoswami7320 2 жыл бұрын
Just to clarify So, the two architectures used in high availability section is a) active-active cluster and b) active passive cluster?
@kaushikdas417
@kaushikdas417 5 жыл бұрын
Thanks for the video. This is very helpful for those like us who are starting with system design. Would you also mind sharing any resources like blogs/books etc.
@TechDummiesNarendraL
@TechDummiesNarendraL 5 жыл бұрын
here you go dzone.com/ highscalability.com/ medium.com/netflix-techblog eng.uber.com/ martinfowler.com/ www.oreilly.com/feed/four-short-links news.ycombinator.com/ ai.google/research/ hackernoon.com/ machinelearningmastery.com/ www.analyticsvidhya.com/ www.kaggle.com/ www.codingthearchitecture.com/
@kolokolowert6333
@kolokolowert6333 Жыл бұрын
Dude, that is cool!
@hitzhangjie
@hitzhangjie 4 жыл бұрын
Very nice! Thank you!
@amolnagotkar3037
@amolnagotkar3037 2 жыл бұрын
Great Info sir 👏
@mahesh116
@mahesh116 5 жыл бұрын
Very good video but certain details missed like when the node in the d list is removed what are the changes in hash map value changes? I know it's very difficult to pack everything. Never mind it's a great learning experience
@TechDummiesNarendraL
@TechDummiesNarendraL 5 жыл бұрын
Thanks and I have already made a video on consistent hashing. Please take a look at description of the video.
@thenainasinghal
@thenainasinghal 4 жыл бұрын
One question - in lru when you delete node from end of linked list, how it's reference is removed from hashtable
@michahubert1179
@michahubert1179 4 жыл бұрын
In linked list node you have key and value (the address of itself). You search for such key/value in hash table and remove it.
@mayankrathore7558
@mayankrathore7558 5 жыл бұрын
Awesome it will be great help if you can talk more about LFU thanks in Advance :)
@navneetbhatnagar
@navneetbhatnagar 3 жыл бұрын
awesome explanation.
@p111calcutta1
@p111calcutta1 5 жыл бұрын
@narendra . Is it possible to optimize the collison case , currently it is o(n) if there are n values for the same key. Also how do you handle the case where mulitple threads are modifying the same key ?
@PoonamSharma-ki4wc
@PoonamSharma-ki4wc Жыл бұрын
@piyush do you have a case when you have n values for same key? If so how do ypu distinguish which one is your value. I think you are talking about collision in hash function, when ,ultiple key hash to same value and hence ypue have multiple key value pairs, for that firstly we use a strong hash that tends to have miminum collisions and even if they collide go by approach told by @Shiv pratap to optimize to log n
@govareddy91
@govareddy91 2 жыл бұрын
When implementing LRU cache, What if there is collision in insertion? So if another (new) key also has hash value 3 and how do we insert it into double linked list?
@jivanmainali1742
@jivanmainali1742 4 жыл бұрын
Do we cache images and how we do that and doesn't that increases size of database?
@saurabhrajvaidya7138
@saurabhrajvaidya7138 4 жыл бұрын
Very nice video and very good content. Thanks a lot 😊
@MsJackyjan
@MsJackyjan 3 жыл бұрын
Does the write around pattern deletes the entry in the cache before updating db? otherwise the cache read would return inconsistent data. 4:14
@yuvrajsingh-sq4wi
@yuvrajsingh-sq4wi 5 жыл бұрын
how eviction will works in case of distributed system ?
@joemcerlane
@joemcerlane 4 жыл бұрын
Thanks for vid, one thing that seemed off, you said getting from the cache is a constant cost, O(1) but wouldn't it be based on the size of the linked list n so it would be O(n) linear search or at O(n/2) if we traverse from either end? Again top video with so much details!
@vmod3985
@vmod3985 4 жыл бұрын
the list is never accesed linearly in this case because it's only used for "sorting". getting is still O(1) because the fields in the hash table are pointing to the nodes and that's how we access them
@ythalorossy
@ythalorossy 2 жыл бұрын
@@vmod3985 I got that we have the association between the hash table and the linked list, but I still having problem to understanding why he said O(1). My concern is because in my mind we need to go through node by node in the linked list to find the index.
@siddhaujain4796
@siddhaujain4796 2 жыл бұрын
@@ythalorossy The HashTable keeps the node's address or the node itself as value against the given key (thus O(1)). The linkedList is there to maintain the Least Recently Used node at the end of it.
@satang500
@satang500 5 жыл бұрын
This is a great video thanks a lot. Two questions. 1. what's the pros and cons for two approaches for fault tolerant repectively - regular internal snapshot and log reconstruction 2. can you post a link or a video for master and slave and how it works for availability? I'm not sure how the slave can sync up the data with master without syncing up
@DenisG631
@DenisG631 5 жыл бұрын
> 1. what's the pros and cons for two approaches for fault tolerant repectively - regular internal snapshot and log reconstruction it's not either/or it both. you use snapshots using specific metrics like time or number of items written and use log for all the events which are happening. The log is cleared when you create a snapshot > 2. can you post a link or a video for master and slave and how it works for availability? I'm not sure how the slave can sync up the data with master without syncing up master propagates the events to the slaves and waits for the ACK. If the ACK is received a new event can be synced
@Gangashritha
@Gangashritha 2 жыл бұрын
Nice Video..Thank you
@mayankrathore7558
@mayankrathore7558 5 жыл бұрын
really appreciated
@sanketpatilvlogs
@sanketpatilvlogs Жыл бұрын
How is key collision handled in your 2 nd scenario when double link list is maintained?
@sahilbajaj2190
@sahilbajaj2190 5 жыл бұрын
How do you handle Cache collision in LRU eviction mechanism, since you are using single entry in bucket, pointing to doubly-linked list?
@bibinbabu330
@bibinbabu330 5 жыл бұрын
I would say another set of pointers for doubly linking, list for bucket list.
@powerhead
@powerhead Жыл бұрын
Searching element in linked list by index has O(n) time complexity since we need iterate from 0 to index value, so we lose hash table O(1) time, right? In this case, why we need hash table at all, if we need to search through the linked list every time we access the value?
@abhinavranjan3599
@abhinavranjan3599 Жыл бұрын
Is linked list used for distributed system as well, wouldn't that be too slow if used in multi-threaded environment?
@debasish2332
@debasish2332 4 жыл бұрын
Very Good. Thank You.
@Vishal-si9uy
@Vishal-si9uy 5 жыл бұрын
Hey, you are doing a great job. Thanks for teaching us such important things. I have a question. 1. If we are replicating server using master-slave architecture for availability. Isn't that suffiecient for making it fault tolerant? Why do we need logging events or capturing snapshots events in such case?
@DenisG631
@DenisG631 5 жыл бұрын
When the node is active again the snapshot and log can be passed to the recovered peer to restore faster
@mrz365
@mrz365 4 жыл бұрын
For log reconstruction, only write operation is needed, so we can omit read operations. As for the fault tolerance, since it's only cache, I think we can just start up a new clean server instead of doing the replication.
@andyd2973
@andyd2973 2 жыл бұрын
Imagine cache nodes being rebooted in production, and having no data. All reads to go database putting a lot of pressure on systems. High chances of increased error rate s till the time cache gets populated
@jorgesmulevici5313
@jorgesmulevici5313 5 жыл бұрын
For the LRU policy, how are reads still going to be O(1) if the values are stored in list? When you re-access key 2 and placed the node at the end of the list you are not updating the indexes in the hash table. How does the cache know which index in the list contains my key (2) when its re-accessed without looking sequentially in the list?
@iliassti4246
@iliassti4246 5 жыл бұрын
Jorge Smulevici just save the key in the linked list node the hash table doesn’t keep order just need the key also the key just noved position, it didn’t change
@singaravelann3671
@singaravelann3671 3 жыл бұрын
In LRU in hashing bucket what will happen if the collision happens which one linked list address will it keep
@eugenee3326
@eugenee3326 Жыл бұрын
In the Write Around pattern, how does the Read operation know that the latest data in the cache could be invalid? The writes always go around the cache, so imagine the following situation. Write to address A1, read from A1, and it causes miss and cache update, then write again to the address A1. Now if I read again from address 1, how would the cache know that it has to re-read the data even though some data is already there?
@ANANDJULU
@ANANDJULU 5 жыл бұрын
thank you so much!
@Eggeater42
@Eggeater42 4 жыл бұрын
Good stuff, thank you. One more thing we can do to improve resiliency when downstream services are unavailable is to use two TTLs (Time to live) : a SOFT TTL and a HARD TTL.
@rahulsharma5030
@rahulsharma5030 3 жыл бұрын
when we have replicas for high availability then why do we need to worry about fault tolerance?If once fails, other will take up and failing both at same time will have less probability and if that happens in worst case,we can rebuild from database?
@sayantanray9595
@sayantanray9595 4 жыл бұрын
Just one point, I am not quite clear here. You mentioned like while finding a node and delete it in constant time from Doubly linked list in LRU. Deleting and adding it at the end is fine but to get the node in doubly linked list will in O(n) time. can you please elaborate little more on that please?
@aup720
@aup720 4 жыл бұрын
The hashtable maps the key to the node. That's how you get the node in constant time.
@voila920
@voila920 2 жыл бұрын
Hey, can someone help me to understand when someone would create their own cache when we already have the systems like redis and memcached ?
@akashshukla3163
@akashshukla3163 3 жыл бұрын
nice to see LP on your t-shirt.
@wyiel
@wyiel 5 жыл бұрын
"Cashing Best Practices" @ 2min. Best section title ever.
@castrothomas7127
@castrothomas7127 3 жыл бұрын
Dude what if instead of doubly linked list you use priority queue... And the priority is given depending on how often it is used
@naughtynhyde9328
@naughtynhyde9328 2 жыл бұрын
​@@castrothomas7127 How will you determine priority on the request? It will have the same priority so they will be used in the order they were received and basically will nothing more than just big array which we are trying to avoid. To determine priority you will have to have additional service running through the whole queue constantly or maybe adding additional data structures to store some statistics and so on...
@rameshbabuy9254
@rameshbabuy9254 5 жыл бұрын
if we have linkedlist for each bucket , then why space issues will come , as linkedlist can extend in size
@jonydcosta1321
@jonydcosta1321 4 жыл бұрын
You are right, but the limitation would be on the total RAM you would have to accommodate the data. If you have unlimited RAM, then I guess you could just keep on using the LinkedList mode that Narendra has explained.
@chuckywang
@chuckywang 5 жыл бұрын
How does write around cache result in a cache miss? Assume data is both in cache and DB. If you update that data and write directly to DB without going through the cache, then the cache would have stale data, and would respond with that stale data. How would a cache miss happen?
@DenisG631
@DenisG631 5 жыл бұрын
due to TTL. key is valid only for a certain period of time
@wishniks
@wishniks 4 жыл бұрын
Thanks a lot for a well-explained video. Concepts look simple after watching them. Just one question. Why is it a requirement to have a fault tolerant cache? Data is anyway persisted in DB, hence if the server containing cache restarts, cache will anyway be built as the requests come in. Am I missing something here?
@jagaranga
@jagaranga 4 жыл бұрын
In-case we read everything back from the DB, the latency involved might be longer. fault tolerance attempts to address the concern.
@ranuchakravarti3277
@ranuchakravarti3277 2 жыл бұрын
Just because every millisecond matters
@26makarand
@26makarand 4 жыл бұрын
Narendra, I really found all your videos extremely helpful. If there is way to make one time donations please let me know!
@TheMdaliazhar
@TheMdaliazhar 6 күн бұрын
It lacks many things present in distrubuted cache for example how Redis cluster shards and routes data (only a fraction of it was discussed), how redis client makes a connection to the redis cluster, etc. It focused more on storage on single node than a distrubuted cache.
@michaelreiche2240
@michaelreiche2240 5 жыл бұрын
buckets should be indexed 0-9 instead of 1-10 for hash % 10 to land in buckets Also - at one point caching is spelled 'cashing' and patterns is spelled 'patters'
@user-oy4kf5wr8l
@user-oy4kf5wr8l 4 жыл бұрын
Thank you bro! lol! we love u!
@escalocity
@escalocity 2 жыл бұрын
How do make sure requests are served in the same order they are requested, as 2 different requests might be updating the same key. Queue could help but since there is a thread pool behind it, you can not guarantee ordering. Also how would you avoid locking issues if 2 threads are updating the same key simultaneously?
@vaybhavshawify
@vaybhavshawify 2 жыл бұрын
Excellent question! The way I am thinking, we could store the value as timestamp_value. If the new write is of an older timestamp, we could drop that write
@somakkamos
@somakkamos 5 жыл бұрын
In ur implementation of lru..u missed to tell us wht wud happen in case of hash collision... How wud it impact the linked list
@jyotsnamadhavi6203
@jyotsnamadhavi6203 4 жыл бұрын
That would still work as it is. The size of linked list will increase more than no of buckets
@deeptinair1453
@deeptinair1453 4 жыл бұрын
Nice a nice video!!!! thanks
@vivekmit
@vivekmit 3 жыл бұрын
Very informative videos. I have confusion and need more visibility. If we talk about the Cache write-through/write-back approach, our cache would be 1st level of storage and the application will write/read data from the cache. My confusion is that my application will fire the JDBC SQL query to fetch data and data will be responded back through the cache. How my cache having the capability to understand JDBC query ... Even if we consider the default cache implementation, data 1st write to Db, and while read request, the 1st hibernate layer will search whether the data is available with cache, if yes that respond back through cache data. In this scenario also no call will send to DB and respond back using cache data. how my cache having JDBC SQL understanding.
@vivekmit
@vivekmit 3 жыл бұрын
My concern is specific to Native SQL query, how it works if we provisioned our hibernate second level cache as write-through/write-back approach as with this cache configuration read/write happens on the cache first. How cache having capabilities to work with SQL native query
@ibknl1986
@ibknl1986 2 жыл бұрын
Thank you.
@manishamulchandani1500
@manishamulchandani1500 3 жыл бұрын
I have doubt regarding caching Consider I have "cache aside pattern" and "in memory cache" in application server is used. I'm looking for Invalidation logic when there is an update. This was the context. I read for critical data like password/financial information we use Write Back policy to ensure consistency. In write through one instance's in memory cache entry gets updated and others can remain stale. So, there is inconsistency in write through My question is same can happen in Write Back, one instance's in memory cache entry gets deleted(invalidated) and we update DB..other instances in memory cache still have that entry. So there is inconsistency in write Back as well? Why do we prefer write back for critical data because same issue is there in write back. If answer is invalidate all instances' in memory cache entry then same can be done for Write through. Which makes me ask question 2. My another question is : We can update all instances' in memory cache entry and then update DB. In this way consistency is maintained so why not we use Write through for critical data like password financial information?
@KrishnaList
@KrishnaList 4 жыл бұрын
Ccould you tell me some books for system design
@alirezaRahmanikhalili
@alirezaRahmanikhalili 3 жыл бұрын
good job
@pivotal-ai
@pivotal-ai 3 жыл бұрын
Why not a min heap w/ update ability on Timestamp of last access? Linked List is still linear to find the actual element.
@karlmagdsick4928
@karlmagdsick4928 3 жыл бұрын
A linked list is O(1) to find either of the two end elements (least recently and most recently used). The hash map's hash chain finds elements by key in O(1) time. Since the LRU list is doubly-linked, you can pull the element out of the list in O(1) time and place at at either end of the doubly-linked list in O(1) time. You're never scanning for, say the 117th most recently used item. We're always evicting the item at the least-recently-used end, removing an element we already have a pointer to via the hash map hash chain, and re-inserting the accessed element at the most-recently used end of the LRU list. Have a look at the OpenJDK implementation of LinkedHashMap if you're curious.
@windowcrystal4012
@windowcrystal4012 4 жыл бұрын
I am confused that why some terms are created for the same meanning, why we use snapshot rather than replication or replica?
@swapnilfilms
@swapnilfilms 4 жыл бұрын
They are different. Replica is something that will change over time. Snapshot won't.
@ankitrawat-acodebreaker
@ankitrawat-acodebreaker 4 жыл бұрын
i guess in write back there is no service for data sync , whenever data is removed from the cache , then it is copied to DB , Correct me if i am wrong
@sajwanmanish11
@sajwanmanish11 4 жыл бұрын
WIth LRU linkedlist, how can we handle collision. Will it be Linkedlist of linkedlist.
@karlmagdsick4928
@karlmagdsick4928 3 жыл бұрын
There are no collisions in the LRU lineked list. One item is accessed, than another. There are no ties for when items were accessed. Even if there were a collision as to which was most recently used, you'd just make an arbitrary choice and treat one as older and one as younger.
@poonamjoshi7576
@poonamjoshi7576 4 жыл бұрын
is distributed cache attached to any server .. U said 1 sever is down then we will have cache miss .. If cache was distributed then we should not lose data from cache no ???
@MADAHAKO
@MADAHAKO 2 жыл бұрын
LINKIN PARK T-shirt??? I love this video already!
@melarryify
@melarryify 5 жыл бұрын
I think most of the talk was on cache rather than distributed cache. May be some parts of sharding/quorum aspects might also need to be included here.
@fenggeliu4241
@fenggeliu4241 5 жыл бұрын
you shard cache? never heard of it
@Vishal-si9uy
@Vishal-si9uy 5 жыл бұрын
@@fenggeliu4241 yes we can, and such cache systems are called distributed cache systems.
@jasonparraga3391
@jasonparraga3391 5 жыл бұрын
Agree! Would appreciate more focus on the distributed aspect.
@EffectiveProgramming
@EffectiveProgramming 5 жыл бұрын
@@jasonparraga3391 : The distributed cache has been already discussed in the other video of consistent hashing which he mentioned during this video. The link is also given!
@DenisG631
@DenisG631 5 жыл бұрын
I guess typical ideas apply. Master/Slave replication. Master for reads+writes/Slaves for reads only. Typical Leader detection. Nothing particular to distributed cache since can be applied to almost any distributed system
@a.yashwanth
@a.yashwanth 4 жыл бұрын
When you delete the linked list the address are still present in the hash table. When you access the address you will get garbage value. How to overcome this?
@willinton06
@willinton06 4 жыл бұрын
By deleting it from the hash table, it's kinda obvious isn't it?
@mayankshrivastava1051
@mayankshrivastava1051 5 жыл бұрын
Question : How about using queue instead of using linked list? to get the LRU nodes?
@TechDummiesNarendraL
@TechDummiesNarendraL 5 жыл бұрын
Delete and updates are o(1) in LL, but in Q you cant access data arbitrarily
@AbhishekGupta05
@AbhishekGupta05 5 жыл бұрын
Queue should work correctly if you want to remove the last accessed item(using front and rear pointers), which may not be the latest accessed item
@tirupatirao7521
@tirupatirao7521 4 жыл бұрын
Hi Sir, could you make system design tutorial w.r.t of credit or debit card systems and other payment systems. will be helpful. thq
@vivekkishore695
@vivekkishore695 5 жыл бұрын
I was looking forward to the part where the data to be cached is so large, that it can't fit in 1 host. And we can scale that horizontally.
@TechDummiesNarendraL
@TechDummiesNarendraL 5 жыл бұрын
It is explained in the consistent hashing video.
SPORTS score update system design | CRICBUZZ System design
33:39
Tech Dummies Narendra L
Рет қаралды 77 М.
System Design Interview - Distributed Cache
34:34
System Design Interview
Рет қаралды 352 М.
БОЛЬШОЙ ПЕТУШОК #shorts
00:21
Паша Осадчий
Рет қаралды 11 МЛН
One moment can change your life ✨🔄
00:32
A4
Рет қаралды 29 МЛН
How does Caching on the Backend work? (System Design Fundamentals)
22:45
Software Developer Diaries
Рет қаралды 32 М.
Redis Crash Course
27:31
Web Dev Simplified
Рет қаралды 607 М.
Amazon Interview question: Learn hashing and consistent hash ring
19:26
Tech Dummies Narendra L
Рет қаралды 154 М.
URL shortener system design | tinyurl system design | bitly system design
34:39
Tech Dummies Narendra L
Рет қаралды 456 М.
Google system design interview: Design Spotify (with ex-Google EM)
42:13
IGotAnOffer: Engineering
Рет қаралды 1 МЛН
How Distributed Lock works | ft Redis | System Design
10:24
ByteMonk
Рет қаралды 2,4 М.
Top 5 Redis Use Cases
6:28
ByteByteGo
Рет қаралды 171 М.