Design Twitter - System Design Interview

  Рет қаралды 440,637

NeetCode

NeetCode

Күн бұрын

🚀 neetcode.io/ - Get lifetime access to every course I ever create!
🥷 Discord: / discord
🐦 Twitter: / neetcode1
📷 Instagram: / neetcodeio
🎵 TikTok: / neetcode.io
🐮 Support the channel: / neetcode
⭐ BLIND-75 PLAYLIST: • Two Sum - Leetcode 1 -...
💡 DYNAMIC PROGRAMMING PLAYLIST: • House Robber - Leetco...
0:00 - Intro
0:49 - 1. Background
1:55 - 2. Functional Requirements
3:30 - 3. Non-functional Requirements
7:40 - 4. High-Level Design
11:39 - 5. Design Details
13:25 - DB Schema
15:30 - Scaling DB
19:48 - News Feed Generation
#system #design #twitter
system design interview
design twitter
design instagram
design facebook
design news feed

Пікірлер: 291
@NeetCode
@NeetCode Жыл бұрын
So are you guys interested in working at Twitter? 😅Btw, don't forget to "Batch" click the like & subscribe buttons. 🚀 neetcode.io/ - Get lifetime access to every course I ever create!
@criostasis
@criostasis Жыл бұрын
You should leave Google for Twitter
@sushantbhargav4652
@sushantbhargav4652 Жыл бұрын
tweet this video to Elon , he might make you CEO, he is weird like that.
@NeetCode
@NeetCode Жыл бұрын
@@sushantbhargav4652 lol maybe i should
@ytshorts1277
@ytshorts1277 Жыл бұрын
Yes hire then next day fire
@wondays654
@wondays654 Жыл бұрын
@@NeetCode you should look at your website, I tried to go pro but for some reason the google api won’t let me sign up. I don’t know if I’m the only one the problem or if it is general.
@Lintlikr1
@Lintlikr1 4 ай бұрын
Being an SWE these days is just insane. Any other job, you'd get hired then learn the system over time and by working with people at the company. As a SWE you have to already know how Twitter works just to get through one of the six or so interviews to get a job fixing bugs or writing new features. Does every other SWE know this shit just from going to school or working in the field for a few years? Ive been a SWE for 10 years and these are all semi-new concepts to me. Ive never once had to design a system like this but I guess now companies want you to be an expert on day one. I thought I could avoid cramming algorithims and system design stuff if I didnt try to get a job at FAANG but now every little startup expects you to be a senior level engineer just to make 140k. I feel like my 10 years of experience count for literally nothing.
@garlicpress6121
@garlicpress6121 28 күн бұрын
10 Years and you barely did system design? Typically getting up in seniority means having to take a higher level approach to problems and leaving the implementation to juniors
@nettemsarath3663
@nettemsarath3663 Жыл бұрын
wow !!! from algorithms to system design, love to see more on system design videos
@damaroro
@damaroro Жыл бұрын
I would love to see more System Design content !! nice video man
@NeetCode
@NeetCode Жыл бұрын
Thank you, more to come!
@sanskarkaazi3830
@sanskarkaazi3830 Жыл бұрын
@@NeetCode I think he meant on your youtube channel haha..
@indiging8330
@indiging8330 Жыл бұрын
@@sanskarkaazi3830 obviously what else could her mean?
@sanskarkaazi3830
@sanskarkaazi3830 Жыл бұрын
@@indiging8330 neetcode has premium courses on his website as well so not there but here.. you get what i mean?
@xoladlamini3675
@xoladlamini3675 Жыл бұрын
Can you talk about Pinterest, or someone link some available content.
@Dayogg
@Dayogg Жыл бұрын
Thank you for explaining in such detail. I learned about sharding, definitely will use in my projects.
@ejun251
@ejun251 Жыл бұрын
Extremely good discussion in this video, more of this please!
@tzadiko
@tzadiko 7 ай бұрын
First time Kim Kardashian has come up in any tech video I've watched
@jti107
@jti107 Жыл бұрын
I guess twitter will be a case study in “does talent matter” and “how interchangeable/disposable are sw engineers”.
@KennethBoneth
@KennethBoneth Жыл бұрын
It will also be a case study on if these software companies are truly over staffed or not. If Twitter survives after laying off so many people it may inspire other companies to consider down staffing
@Mattarii
@Mattarii Жыл бұрын
@@KennethBoneth I think the main issue with scaling down on employees is that the remaining employees will essentially have to monitor and handle the same amount of work as before scaling down, which will cause additional stress and probably a less than healthy work life balance.
@bryanyang7626
@bryanyang7626 Жыл бұрын
Not really, Tesla and SpaceX both are well known for the horrendous work environment. So it depends on the management and the owner of the company in this case.
@Mattarii
@Mattarii Жыл бұрын
@@bryanyang7626 that's true, might not work well with other companies once people start realizing their lives are worth more than slaving away
@KennethBoneth
@KennethBoneth Жыл бұрын
@@Mattarii That is true if you were properly staffed to begin with. If twitter is as overstaffed as many people believe, then a large chunk of employees are effectively doing nothing. IF twitter goes from properly staffed to understaffed, you are correct. If twitter is going from overstaffed to properly staffed, then that won't happen.
@angelsancheese
@angelsancheese Жыл бұрын
Looking forward to part 2!!! More in-depth
@GeorgeHFonseca
@GeorgeHFonseca 4 ай бұрын
Your content is way, WAY better than the others on KZbin! Great work!
@dukekong2412
@dukekong2412 Жыл бұрын
I can't help but find it slightly hilarious that you released this video during the ongoing controversies happening at Twitter. But in all seriousness, amazing content!
@fauxz3782
@fauxz3782 Жыл бұрын
Musk will hire him
@SunilPatil-hs8wd
@SunilPatil-hs8wd Жыл бұрын
Its because Musk tweeted the HLD of twitter on twitter. You can see that in the thumbnail of this video too
@respondo
@respondo Жыл бұрын
Very much enjoyed the video, the explanation, the simplicity and the clarity it brought out. Thank you
@NeetCode
@NeetCode Жыл бұрын
Glad it was helpful!
@RandomShowerThoughts
@RandomShowerThoughts Жыл бұрын
the biggest thing about sharding is that we could potentially lose the joins, and it adds a huge layer of complexity on the application.
@hitarthdesai5271
@hitarthdesai5271 Жыл бұрын
Amazing video, this has made me curious about systems design roles in industry
@tiskahar9738
@tiskahar9738 Жыл бұрын
This is a fantastic example of a realistic architecture screen. I would note for viewers that you will almost certainly not be able to think of and describe everything that was covered here and as someone who conducts 3 or 4 of these every week, I don't expect candidates to cover everything here in the 20-30 minutes I have with them. But as you go through this video, the issues presented scale really well with the expectations that go along with the seniority of the candidate and position. We actually skip a lot of the preliminary setup so that we can delve into the more complex issues for more senior candidates. If you're a mid level, I'm not expecting you to come at me talking about batching out feeds and dynamically updating them based on high popularity tweets.
@alexd7466
@alexd7466 Жыл бұрын
no, with such test you filter already for ex-twitter employees. That would be fine if you build a social network, but you'd miss out on all the all the brilliant devs who for example designed large e-commerce or data-pipeline architectures, because that requires a very different approach.
@kaixuanhu8332
@kaixuanhu8332 Жыл бұрын
Love your content, your video help me land a position at Twitter one year ago. but I just got laid from Twitter and will start checking your video again 😅
@NeetCode
@NeetCode Жыл бұрын
I'm sorry to hear that, wish you the best - it's only a matter of time!!!
@tct1787
@tct1787 Жыл бұрын
me too😂😂
@eldavimost
@eldavimost Жыл бұрын
Loved it! The only issue I see is sharding having all the people who follow each other in the same shard. That's just not possible, as a friend of yours will follow someone in another shard group at some point. I haven't got a good answer for that yet, apart from saying we should use a GraphDB here that hopefully is optimised for sharding this kind of data...
@arwinvinnysardana3266
@arwinvinnysardana3266 7 ай бұрын
Yes, that seems like a big oversight. Each shard will have a subset of a users followees, so the proposed user id as a shard key really doesn't do anything for us.
@Socsob
@Socsob 7 ай бұрын
Yeah I felt like I was missing something when he said sharding and scrolled down to the comments to confirm
@salient244
@salient244 4 ай бұрын
Just paused at that part, seems incorrect. The best sharding I think may be tweet id (assuming using chronological IDs like snowflake) as people are generally accessing the latest tweets so can grab them in a single request if it misses cache
@eldavimost
@eldavimost 4 ай бұрын
@@salient244 yeah, but still you'd need to store the friends relationships somehow and you'd get into the sharing issue when it scales up
@TheSdl79
@TheSdl79 Ай бұрын
You've got it wrong. The idea is to have all the _followers_ of the user in one shard. This way, when the user posts a tweet, you would get all their followers ids from one shard with one query. Then you'd use this list of ids, to update their respective feeds with the tweet. When the user request their feed, they get it pre-computed from the cache, not built on-the-fly.
@romeopeter1922
@romeopeter1922 Жыл бұрын
Wow! That's a lot to take in maybe because I'm sleepy but sparked at the same time. Put out more of this please.
@thatsJD
@thatsJD Жыл бұрын
I loved your video, very much and thanks a lot for he afford you made. These are the question we actually face when you are working on the BE side. One small question, If someone asks you, what kind/type of architecture is this? What will be your answer?
@roycechua
@roycechua 4 ай бұрын
I can't believe that I just found this channel now. Great content
@jordanhasnolife5163
@jordanhasnolife5163 Жыл бұрын
Nice video! Gotta love some systems design
@randysong823
@randysong823 Ай бұрын
Great video! One question (or perhaps a mistake), in 18:20, you say all the people this guy follows should be on one shard but I don't think that's possible. If person A follows B and C, then B and C should be on one shard. if person E follows C and D, C and D should be on one shard, but its already on a different shard. Maybe B,C,D are all one shard, but as long as each person follows another different person, we will only have one shard.
@karanbhatia2834
@karanbhatia2834 Жыл бұрын
This level of quality content is available for free, it blows my mind! Also, I am churning through your Blind 75 list of questions and I am loving your solution videos.
@umarqureshi8499
@umarqureshi8499 7 ай бұрын
how is this a quality content?
@arwinvinnysardana3266
@arwinvinnysardana3266 7 ай бұрын
​@@umarqureshi8499what's wrong with it?
@asdfasdf9477
@asdfasdf9477 10 ай бұрын
One of the defining features of twitter is timely notifications about new tweets from people you follow. Could you please describe how could it be implemented in this architecture? Likes and comments allow users to attach their content to a potentially popular tweet. How would it affect our storage layer? What challenges, if any, we would face with multi-az deployment of such system? Thank you for your time and interest in our company.
@maximilian19931
@maximilian19931 Жыл бұрын
Caching the Feed page in the CDN and purge it on update(feed is tagged with User_ids), the infrastructure is basically a multi layer data retrieval, uid->followee->tweets(sorted by timestamps) and then merge to get the final result. The uid->followee mapping can be compactly stored and updated if needed. (K/V or RDB) followee->tweets would be a sharded DB with all tweets posted. (K/V). it would just be a simple backend and most of the load would be handled by the CDN.
@marspark6351
@marspark6351 Жыл бұрын
That more or less is I think what he described for his feed cache description. But it doesn't solve the problem he brings up where we don't want to update all the followers' feed cache whenever a popular user posts a tweet. Also, I don't know how to do it, but when you say "on update", I'm assuming that whenever a person posts a tweet, all the users following that person gets "updated". In that case, then only thing that needs to be changed is inserting that new tweet into the feed (and probably popping out whatever oldest or least important tweet that is in the feed that this new tweet will replace). In that case, I don't think retrieving and merging all the relevant tweets each time there is an "update" makes sense. I think that's why he brought up pub/sub. So it's just a queue where whenever a new one comes the least important one gets popped out.
@TheIntraFerox
@TheIntraFerox Жыл бұрын
​@@marspark6351 Maybe it's possible to determine a "popular" user and when those users create a tweet, only cache that tweet instead of allowing a message to go through the pub/sub when they post a tweet.
@gmanonDominicana
@gmanonDominicana 10 ай бұрын
Once I had an interview explaining how to design something. I totally missed the point. This definitely give us a clear idea. It's not about writing a user story, and not even building the actual application, but identifying the most critical points and possible components and to come up with how to solve it. Thanks again.
@andrewlee7574
@andrewlee7574 Жыл бұрын
What a nice video, I learnt a lot even being a junior developer. Btw, how can I find the official twitter engineering paper you mentioned at the end?
@antwanwimberly1729
@antwanwimberly1729 11 ай бұрын
I’d try checking their engineering blog for leads.
@jacksonashby7471
@jacksonashby7471 Жыл бұрын
we need more of these for sure
@divyareddy7622
@divyareddy7622 Жыл бұрын
thank uuuuuuu can you please upload more videos on system design and object oriented design. I know you might be busyy but would mean a LOTT!!!!
@OswinChou
@OswinChou Жыл бұрын
If you have the capacity for asynchronously pre-building timelines for all (active) users, why don't you increase the capacity of the cache layer for the RLDB, or store the tweets in a fast KV NoSQL?
@TheSdl79
@TheSdl79 Ай бұрын
Probably, having NoSQL KV-store with such massive reads you'd have to deal with its sharding anyways. Don't think you'd just set up Cassandra and start throwing in nodes to the cluster mindlessly. So, author, choosing SQL DB, just makes that logic explicit.
@punarvdinakar
@punarvdinakar 8 ай бұрын
That initial diss on twitter is everything 😂😂
@tyronedamasceno6706
@tyronedamasceno6706 Жыл бұрын
That’s amazing how this kind of large-scale system can grow and become so complex with amount of components and “moving parts”, also it’s impressive how it works with a massive amount of users and data storage like petabytes. In the end, I didn’t understand if your solution was using sharding or not on the database, if it is using, how do you solve the issue about the sharding-key, ‘cause it looks like not possible to use the “every account followed by someone” strategy due the reasons you even talked about. Is it possible to have sharding and reading replicas at the same time? And how to handle it, using many load balancers, each one after sharding for a single replicas cluster?
@lucassaarcerqueira4088
@lucassaarcerqueira4088 5 ай бұрын
I was left with the same impression. I don't see how this sharding could work
@alexanderradzin1224
@alexanderradzin1224 11 ай бұрын
Thank you for interesting video. I however doubt that relation database can store the tweets. I've just asked to design twitter during a job interview and constructed something very similar. But I suggested to use aerospike for messages using the following schema: id->list off messages. Aerospike is horisontaly scaled, so there is no need to think about sharding.
@ROBIN12JBJ
@ROBIN12JBJ Жыл бұрын
The abstract design is vital! Now I have realized this point.
@mayankkumargupta9601
@mayankkumargupta9601 Жыл бұрын
Literally Amazing man. Take a bow🙇‍♂️
@josephp1263
@josephp1263 Жыл бұрын
I almost spilled my coffee when i heard the word "How hard can it be?" LOL
@user-cy6uq7qd4m
@user-cy6uq7qd4m 9 ай бұрын
which tool are you using to draw the diagrams?
@ivanjermakov
@ivanjermakov Жыл бұрын
Speaking of popular users. We can separate tweet data by some follower threshold (say 10k followers) and, when popular profile post a new tweet, we only need to update that feed. Every normal profile will check that feed in case they follow popular profiles.
@SameAsAnyOtherStranger
@SameAsAnyOtherStranger Жыл бұрын
So...use the average Twitterer's tweets as load dampening. They should do that. It will make Twitter even less popular.
@rizthetechie
@rizthetechie 9 ай бұрын
Agree on the part that, the data is more on relational side. But why can't we put the tweet in any NoSql db like cassandra, scylla. As from our follow table i know which followee's tweet i have to fetch. Now that i know, i simply have to search in shards the followee's tweet stored.
@rajatsaraf237
@rajatsaraf237 Жыл бұрын
If we shard based on a used id, won't it become a hotspot (if user is a celebrity or has large no of tweets)?
@ankitasingh734
@ankitasingh734 Жыл бұрын
Simply amazing content
@dannysi1234
@dannysi1234 Ай бұрын
This is great! Thank you!
@roxhensm.8071
@roxhensm.8071 Жыл бұрын
What software and device do you use for the drawing?
@mehrdadk.6816
@mehrdadk.6816 Жыл бұрын
Thank you so much for this video and its good content. Actually one thing to correct maybe is that 12:24 it's not good to save authorization token in db due to security reasons. so maybe if one says that in interview , the interviewer thinks the interviewee does not care about this, and reject him/her
@zhenghaohe4727
@zhenghaohe4727 Жыл бұрын
do you mean by passing user ids along with the request implies that the auth token is stored in db? because I don't see him mention it explicitly in the video where to store auth tokens. Also out of curiosity where do we store the auth tokens then?
@cesarvspr
@cesarvspr Жыл бұрын
@@zhenghaohe4727 we don't store them, we validate them against our secrets
@slaytyxperry
@slaytyxperry Жыл бұрын
Thank you man
@_jko
@_jko 7 ай бұрын
Don't forget ads. Imagine how complex this whole thing becomes when we add in ads.
@smittyplusplus
@smittyplusplus Жыл бұрын
I would send the tweet timestamp from the client. If you handle it server-side and something breaks and delays the server-side ingestion of the tweet, you'd have an incorrect timestamp. ("Wow, what an amazing touchdown!" posted 2 hours after the touchdown and way out of context on feeds etc)
@somebodyoulove
@somebodyoulove Жыл бұрын
This is great. I loled at 0:48 .This video is neet.
@dantedt3931
@dantedt3931 10 ай бұрын
Great video. Learnt a lot.
@marspark6351
@marspark6351 Жыл бұрын
I have a question on how on 23:46 on how that "update of the feed upon request instead of during when a tweet is created" would work. So would the feed of a user keep continuously get updated via the message queue whenever there's a new tweet, except for the tweets of the popular one? And when that user requests the feed, it will somehow just fetch that missing tweet and fill it in the feed? How would that work? Isn't that the same issue as what it's described at 19:57 where 19 of your 20 tweets could be cached but you'll have to go to the disk to find that one tweet?
@TheSdl79
@TheSdl79 Ай бұрын
Before returning the feed, the app server would check if the user follows any celebrity (one query to follow table). Then get the tweets of the celebrities which user follows from the cache, and inject them into the feed based on the timestamp. This approach has significant downsides like increasing latency for all users, so I believe this problem is addressed differently in real world.
@spork1125
@spork1125 Жыл бұрын
Where do those caches live? Are they separate servers? Or are we caching on the app servers?
@Thomas-lv1dc
@Thomas-lv1dc Жыл бұрын
Ngl as a aspiring software engineer, I find this video helpful in terms of macro design. New video style over the different duties of a software engineer? 👀👀
@tukkanen
@tukkanen Жыл бұрын
I wouldn't combine reads of tweets with "reads" of videos into a single number of data we're going to read from our "storage" as storing videos and streaming videos and storing and reading text tweets + meta data are completely different tasks which access and deals with data in a completely different way.
@chrishabgood8900
@chrishabgood8900 9 ай бұрын
considering how many joins you would have to do in a relational DB, it would be hard to justify that for twitter.
@zertbrown4642
@zertbrown4642 Жыл бұрын
my IT classes coming in clutch
@programadorpython
@programadorpython 6 ай бұрын
omg, you're insane. thank you!
@kSergio471
@kSergio471 10 ай бұрын
If sharding by user id then, to retrieve a single tweet (e.g. by a direct link), you would need to request all shards. Is it something tolerable or how do you overcome it? And what about hot user problem? Sharding by user id does not work well in this case.
@TheSdl79
@TheSdl79 Ай бұрын
Yep, but there is no requirement in this case to be able to request tweet by id directly without knowing the author of the tweet.
@Sudarshansridhar
@Sudarshansridhar Жыл бұрын
I don't even have a twitter account or did get the reall need. So do the interviewers gives inputs what is the twitter is used for?
@MrRetroboyish
@MrRetroboyish 8 ай бұрын
I appreciate the effort and care you put into this video but I think it could use a little more focus. Especially at the sharding-for-writes portion. You jumped around a lot to digressions that made that line of thought hard to follow.
@siddharthsingh7281
@siddharthsingh7281 Жыл бұрын
I was waiting for something like that
@ismailmo4
@ismailmo4 Жыл бұрын
great video!
@doBobro
@doBobro Ай бұрын
It's so silly and cursed situation with system design interviews. Usually you have functional requirements to support 10e6+ users but you can't make even remotely viable design to support these requirements. It's always a hand wavy "a thing" you can't apply to real life in any way. And the most outrageous thing: in real life you never design for scale without already working product. It's always post tweaks for current and near future loads, numbers you have on hand.
@veliea5160
@veliea5160 Жыл бұрын
I understood why the userId helps as shard key but I did not understand why choosing "tweetId" as shard key does not help. Why to we have to query all the shards if we shard based on "tweetId"? can someone explain pls?
@semenivanoff8615
@semenivanoff8615 6 ай бұрын
Number of users doesnt matter as you should design scalable system that grows in building blocks. And as userbase grows you add blocks.
@progdynamic3114
@progdynamic3114 Жыл бұрын
I have a question. in most of the read internsive applications . most of the design is to add a cache layer like redis to block the db traffic. Can i not add any cache but add as many as read-only replicas of mysql to distribute the traffice ? as cache also need to consider the sync problem between redis and mysql. but read-only replica can get rid of this hassle .
@marspark6351
@marspark6351 Жыл бұрын
I would believe this has less to do with whether it's SQL or noSQL, but probably more to do with that Redis makes better use of RAM than mysql. Don't take my word tho. Just a possible assumption
@Angelslo690
@Angelslo690 Жыл бұрын
Why you need relational db, all this relationship data you can store in document db as json for high performance, low latency and scalability. Usage of relational db will not be efficient in this scenario because we need to achieve high availability, we need eventual consistency so NoSql Mongo db is preferred over relational db in this scenario. Correct me if I am wrong.
@jenokalinszki1696
@jenokalinszki1696 Жыл бұрын
I am a little confused about the DB schema - can someone explain why would we favour indexing based on the follower rather than the followee? What's the advantage here? I would assume the former is more logical to implement but I can be wrong.
@NeetCode
@NeetCode Жыл бұрын
If we wanted all the people that user1 follows (in order to generate their news feed) we could run a query like: SELECT * FROM followers WHERE followers.followerId = user1 Notice we are filtering by followerId.
@ketanambati4413
@ketanambati4413 Жыл бұрын
Whenever we create the newsfeed we want to populate it with tweets of people that a user follows(followee). So when we index the follower, we can query the followees relatively quickly, meaning that we can get all the people that a user follows, which makes it easier to create their newsfeed.
@ismailmo4
@ismailmo4 Жыл бұрын
I understood it as: when the timeline is loaded and we need to populate tweets, you're going to be querying for tweets based on the follower of that tweet as opposed to the person being followed (followee). So if we say the user loading the timeline is the current_user a query (in a simplified world) would be like: SELECT tweets.content FROM tweets WHERE tweet.follower_id = current_user.id Note how our WHERE clause is on follower_id of that tweet and NOT the person who wrote that tweet (followee).
@jenokalinszki1696
@jenokalinszki1696 Жыл бұрын
I see. Thank you all for explaining this!
@i.eduard4098
@i.eduard4098 Жыл бұрын
Never had a twitter account. Idk how to even use it. I suppose I can do the CRUD for tweets, and the chat between users with SingalR, but the feed would be limited to hashtags or simply categories a user has the highest count. Anyway I dont even have a job and I would do a shitty demo in angular, who am I to talk about this. The sharding, indexers I really have no experience and a lot of other shenanigans.
@gazijarin8866
@gazijarin8866 Ай бұрын
There shouldn't be any userId in the POST /v1/tweet/create endpoint. This is because we will get the id of the user initiating the request from the authentication token in the request header. Putting sensitive information like authentication tokens in the request body is a security risk
@johnsaenzc
@johnsaenzc Жыл бұрын
Gracias - Thanks, great video.
@yiyao1522
@yiyao1522 Жыл бұрын
Correction 9:01 We can also implement sharding in most nosql databases.
@NeetCode
@NeetCode Жыл бұрын
That's correct, I meant that while NoSQL is easier to scale (automatically or by specifying a shard key), we can still scale relational DBs via sharding.
@-_______________________.___
@-_______________________.___ Жыл бұрын
Nice catch boss
@akashbhardwaj7810
@akashbhardwaj7810 Жыл бұрын
What books / sources did you refer to get a strong grip on system design?
@NeetCode
@NeetCode Жыл бұрын
DDIA is the most comprehensive resource (assuming you have at least some experience). Also, most companies (including twitter) release blog posts and white papers about technical challenges they faced and how they overcame them. I think many beginners miss these, but they are an extremely valuable and free resource, which is why they are commonly referenced by system design textbooks.
@akashbhardwaj7810
@akashbhardwaj7810 Жыл бұрын
Thanks!!
@sezer6200
@sezer6200 Жыл бұрын
@@NeetCode Is there a central url where you find those blog posts or do you just google them?
@meepk633
@meepk633 Жыл бұрын
A good place to start is by learning the classic OOP design patterns. It's less about the OOP and more about the patterns.
@marspark6351
@marspark6351 Жыл бұрын
12:48 Can you clarify what you meant by "I shouldn't be able to pass in your uid"? Are you saying that function should actually not take uid as input?
@StockDC2
@StockDC2 Жыл бұрын
Pretty sure he means that someone shouldn't be able to use something like Postman to send a request with someone else's user id and retrieve all of their tweets.
@sindhu8480
@sindhu8480 Жыл бұрын
Can you please do video recommendation design
@guld3n
@guld3n Жыл бұрын
End of min 8, a relation between a follower and a followee is not the same as a relation in a relational database. So it's not a reason to think of one.
@ankitsheoran1788
@ankitsheoran1788 8 күн бұрын
If user A follows B and C and B follows back to A then all three should be on same shard and same way if B follows 10 more people and even one person follows back then all those 10 should be on same shard and it goes on with all data on single shard . looks like very abstract way , i am not sure why people not think little more rather thn explaining that abstract way
@michaelscofield2652
@michaelscofield2652 3 ай бұрын
I would argue you need an index on both followee and follower because in twitter you can see both ways
@arthur723
@arthur723 Ай бұрын
At 18:12, how do you manage to get all the users one follows in a single shard? It seems strange to me. If that can work, then all the users need to be in a single shard, which fails the purpose of sharding.
@hakimmalik6995
@hakimmalik6995 Жыл бұрын
Nice Video, how about design of an online bank ?
@davidkolosowski5529
@davidkolosowski5529 Жыл бұрын
What this seems to miss is that what's important about twitter is the datastructure that represents a timeline of tweets. There are systems that generate that then there are systems that inject tweets into that timeline. These can be ads or they can be other tweets that the ML systems want to promote... etc. That's the DS that is at the heart of what twitter is. The tech here should be built around that concept NOT the other way around.
@marspark6351
@marspark6351 Жыл бұрын
isn't what you are describing the "feed" part that he's describing? I'm confused why else you need a database ordered by timeline
@DarrienGlasser
@DarrienGlasser 6 ай бұрын
Great video, I even got a similar answer so I know it's good ;D
@purdysanchez
@purdysanchez Жыл бұрын
It doesn't seem like there's a good general solution. What works for the average user, doesn't work well for super big users. I heard that Twitter separated users with more than a certain number of followers into a separate use case. Not sure if they ever solved it.
@kewtomrao
@kewtomrao Жыл бұрын
Wat tools do you use to draw?
@maywilliams82
@maywilliams82 5 ай бұрын
It will be helpful if you present it in a more realistic interview Q&A kind of scenario, as often the interviewer interrupts the process, asks a different question, or asks to take a different approach. The mocks presented only as a monologue do not serve that purpose.
@thekauer
@thekauer Жыл бұрын
Would it make sense to only store the tweetId of the tweets in the feed cache, so when someone popular edits their tweet, the edited version will probably be in the tweet cache already, from where we can quickly grab it?
@merick1453
@merick1453 Жыл бұрын
You’re already pushing tweet related info to the feed cache why would we limit it to tweet id only? That’s actually more of an overhead since we’ll need to do another request to actually fetch the tweet detail. Also for update we can always use a lastUpdate timestamp to compare and only push to the cache if it changed
@kinshaabid3063
@kinshaabid3063 Жыл бұрын
Nice ! could you do part with how the data is index and search optimised ?
@PhillyHank
@PhillyHank Жыл бұрын
Thanks!
@Nonchalant2023
@Nonchalant2023 Жыл бұрын
so what's a batch RPC? Asking for a friend...
@Tony-dp1rl
@Tony-dp1rl 6 ай бұрын
Seems to be missing the peak throughput in the initial design 20 billion reads per day is not as useful a metric as how many per minute or second at peak load.
@xx-gx1ig
@xx-gx1ig Жыл бұрын
Wouldn't the feed cache take up a ton of memory? i.e. - 200 million users - 1mb per data per tweet - 100 tweets pre-cached in a feed format is 20PB of memory. Even sharding it by 1000 times is extremely large for a memorystore is that just fine to deal with?
@NeetCode
@NeetCode Жыл бұрын
The feed cache will not contain the images and media, so avg tweet size will be closer to 1kb. 20TB of memory is expensive, but feasible.
@xx-gx1ig
@xx-gx1ig Жыл бұрын
i guess you wouldnt store the file, just the url of the object storage, but it still seems insanely large
@xx-gx1ig
@xx-gx1ig Жыл бұрын
@@NeetCode got it, makes sense thank you!!
@marspark6351
@marspark6351 Жыл бұрын
@@xx-gx1ig also do we really need 100 tweets cached? Seems like the user experience would be fine if you had 20~30 tweets cached and once you scroll past those, you wait a bit to load the next set of tweets
@1shadyholic
@1shadyholic Жыл бұрын
too bad that you didn't mention how likes system works. I was always curious how it is done that someone clicks like and immediately gets total amout
@ourangzebkhan6516
@ourangzebkhan6516 11 ай бұрын
which hardware you use for writing?
@deeptishetty6074
@deeptishetty6074 Жыл бұрын
Great video. Working the hashtag in to this design would have made it even better.
@nikolqy
@nikolqy 7 ай бұрын
I always figured using Goalgn for the REST api and SingleStore as the backend DB would offer the most scalability. And then of course caching with Aerospike or Tarantool. SingleStore has graph too I think as well as most data models. On top of that, it has really good compression.
@vincentlextrait3092
@vincentlextrait3092 Жыл бұрын
How about starting from the data model rather than the architecture? And let architecture emerge from constraints on use cases? Enterprise applications 101.
@abhinee
@abhinee Жыл бұрын
Appreciate if you can mention relevant cloud services like spanner for relational database or elastic cache or S3 or gcp file storage, also tweet notification is a good case to cover. Does anyone really shard dbs these days and is table partition same as sharding? How will the spark cluster scale?
@NeetCode
@NeetCode Жыл бұрын
Good suggestion, will keep in mind for future videos!
@zuowang5185
@zuowang5185 3 ай бұрын
why do you index on follower, instead of making 2 db index on both
@Brosales1414
@Brosales1414 Жыл бұрын
I'm confused on how pub/sub works? can anyone explain to me what its suppose to do? if you can explain like I'm five that would be great!. THX
@IAmNumber4000
@IAmNumber4000 Жыл бұрын
If the interviewer is Elon, all you need to do is remember the word “turboencabulator”.
@blueghost512
@blueghost512 13 сағат бұрын
I don't think that sharding on UID is a good approach, I would go with sharding based on date (a shard for each month). thus making feed fetching simpler and faster. at most you will hit two shards at the same time. and maybe you only need replicas for the last 3 shards (last 3 months). And I'm not sure about saving pre-computed feeds. is it really good practice?
Design Youtube - System Design Interview
26:04
NeetCode
Рет қаралды 238 М.
How to Implement Blackboard Architecture in Unity C#
28:57
git-amend
Рет қаралды 3,1 М.
ПЕЙ МОЛОКО КАК ФОКУСНИК
00:37
Masomka
Рет қаралды 1,7 МЛН
Glow Stick Secret (part 2) 😱 #shorts
00:33
Mr DegrEE
Рет қаралды 15 МЛН
ШЕЛБИЛАР | bayGUYS
24:45
bayGUYS
Рет қаралды 542 М.
System Design Interviews: 10 Key Principles (with ex-Google EM)
41:14
IGotAnOffer: Engineering
Рет қаралды 11 М.
Twitter system design | twitter Software architecture | twitter interview questions
36:56
Google system design interview: Design Spotify (with ex-Google EM)
42:13
IGotAnOffer: Engineering
Рет қаралды 947 М.
20 System Design Concepts Explained in 10 Minutes
11:41
NeetCode
Рет қаралды 831 М.
How I Mastered System Design Interviews
10:22
Ashish Pratap Singh
Рет қаралды 49 М.
Facebook System Design Interview: Design Twitter
24:22
Exponent
Рет қаралды 66 М.
System Design: Design a URL Shortener like TinyURL
16:00
Code Tour
Рет қаралды 75 М.
Design a Payment System - System Design Interview
31:40
High-Performance Programming
Рет қаралды 393 М.
🤯Самая КРУТАЯ Функция #shorts
0:58
YOLODROID
Рет қаралды 3,2 МЛН
M4 iPad Pro Impressions: Well This is Awkward
12:51
Marques Brownlee
Рет қаралды 5 МЛН
Samsung or iPhone
0:19
rishton vines😇
Рет қаралды 4,2 МЛН