‫What is going on, guys?
‫My name is Hossein, and in this video I want to build with you guys a U.
‫RL shortener.
‫So we're going to go through a system design to interview questions or this is one of the most interesting
‫ones, right?
‫It's very common and it's really easy to build.
‫But before we jump into the video, guys, I want you to always for any of these exercises, design
‫system design, you are the system designer, and I want you to treat whatever this is.
‫This is the blank canvas that you put your own unique design in, OK?
‫And.
‫Be proud of whatever you put in there, because it is an art, right?
‫I consider system design as an art.
‫Some people might not agree, but there are literally thousands and thousands and thousands of way to
‫solve any given problem.
‫And today's problem is you are the shortener.
‫So whatever I'm going to come up with is not going to be perfect.
‫Whenever a 30 year experience professional either is not perfect because there is always pros and cons
‫for every system design and whatever you come up with on it.
‫Enjoy the process because it's going to be your baby and it feels damn good if you design something
‫of your own without actually looking through the best practices right before you jump into best practices,
‫just do something, do a bad design and start to improve it.
‫Keep in mind that everything can be improved.
‫Well, that said, how about we jump into the video and start building our all your own show?
‫So what is it?
‫You know, it's a system that you give me a whole large euro and I'm making it into a tiny URL.
‫And if you give me that tiny URL, I'm going to give you or redirect back to the original.
‫Longyear very useful for social media because I don't know or very useful for Hey Tech this year.
‫It's easy to remember than you are this big, right?
‫All right.
‫That being said, the first design that comes to my mind and it's no longer it's not it's not it's not
‫perfect by any means.
‫But the first design is I'm going to have a database here, OK?
‫And an excuse me, guys, as I navigate this thing, because this is the first time I do this.
‫But here there's a database.
‫I actually like the other databases that I bought for you guys.
‫A special thing here.
‫All right.
‫So we have a database, guys.
‫All right.
‫This is a beautiful database.
‫And all right, we have a database.
‫How about we add a computer, guys?
‫Right.
‫As I add another computer.
‫As the client tried.
‫And I don't know if this sounds good, looks good, so we have a database, we have a client, but since
‫this is kind of a Web application, we kind of need also a Web server.
‫Correct.
‫But we had a Web server, Web site, Web server.
‫They go, that looks like a Web server.
‫So that's where our application logic will lie.
‫This is my database and this was the declined that request a U.
‫RL to be shortened.
‫And the same logic that reversed a short you are back to a long one will live under the same code base,
‫right?
‫I think so, unless you guys disagree.
‫All right.
‫So this is a database.
‫And here's the first design that comes to my mind.
‫I am going to use a table like this in the database and it's going to be like an ID and there will be
‫another field called the URL.
‫And pretty much that's it.
‫That's it.
‫You are the longer you will come here.
‫Right.
‫That's the longer you're out all night long.
‫You URL excuse my handwriting here guys, but I'm still working on the sketching pad thing and this
‫guy is going to be a serial.
‫Field and polls, because there is a cereal field, and as soon as it feels like every time you add
‫a row and you row here, this is will be auto generated for you.
‫There's going to be one, right.
‫Or two and three and so on.
‫And then it's going to be a 64 bit.
‫So the maximum number we're going to get is sixty four minus one, which is a huge number.
‫How about we actually check how big is this number.
‫That's the biggest sixty four Bettinger.
‫Look at this.
‫It's really, really huge right.
‫It's around 20 digits.
‫Right.
‫20 characters if you will.
‫So obviously it's a huge number.
‫Right.
‫So this is how many rows I can have in my table.
‫But it is big that you can store this much.
‫All right.
‫So what will happen here is if you made a request, right, you will just specify that you are.
‫And I think that's enough.
‫We'll go we're going to walk through that.
‫Right.
‫So let's say I'm going to shorten a big you, Auriol, and you're going to start writing this here and
‫you're going to get a number.
‫Right.
‫So let's walk through an example.
‫How about that?
‫I might make a post request here.
‫Right.
‫Both requests slash and you're going to give you all right that that both requests will be received
‫by the server and the server will establish a TCP connection to the database.
‫Right.
‫I'm assuming then he was my school or the Postgres.
‫I'm I'm going with relational for consistency reasons here.
‫So now I'm going to establish a connection here and I'm going to write right to this is an insert statement
‫immediately.
‫I'm going to do an insert sequel's insert and I'm going to specify the URL and what the database will
‫give me back is a number, either one to give me which sequence and that I'll take that to sequence
‫it and return it back to the client.
‫So the order will be slash one, slash two that that is slash 17 and so on.
‫Right.
‫So that's the original design.
‫Right.
‫Let's go through that and we're going to talk about the pros and cons of this design, obviously, guys.
‫But that's that's one design, right?
‫If you don't really care about having custom URLs that work.
‫Right.
‫But let's say I break down the database design a little bit here.
‫Since this is a database post or a relational database, I want this to have an index entry into this
‫skull.
‫Yeah, I can change this.
‫How about that?
‫I'm going to have this as an index.
‫I need an index on this, right?
‫Probably a primary key.
‫That's that's going to be my primary key.
‫Right.
‫And going to be by default.
‫Primary is going to have an index or look up on this guy is going to be extremely fast because it's
‫an integer.
‫It's only 64 bit.
‫So the index size is so tiny.
‫Right.
‫Plus, we don't really make a good request example showing you get a request.
‫So let's just walk through a get request example.
‫So the client will make a request, says, hey, get.
‫Seven, right?
‫I want you all to watch them and it's going to be the domain slash seven, right?
‫And that server will receive that is going to make a query and this time is going to be select right
‫to the database.
‫And the database will select where I.D. is equal seven.
‫My God, how fast is this, because this is an indexed column and it's an integer, so the index is
‫so tiny.
‫All right.
‫So the query will be extremely fast and we're going to get back the results.
‫OK, this is the URL.
‫The the the the the and the server will return that and return the oil to the user suite.
‫So that's that seems OK.
‫That seems OK.
‫Right.
‫So the only index technically that we need is just this.
‫We don't need another index and extremely fast.
‫So let's start to scale this up a little bit.
‫I am writing I'm posting a lot of URLs.
‫Right.
‫And I'm getting this incremental yds rame.
‫So I'm going to get up to like a million or two million.
‫Three million that does this database can handle definitely can handle databases, can handle three,
‫four billion records easily.
‫And writing will.
‫The writing becomes slower if I have a billion rows here.
‫Absolutely not.
‫Well, we're going to talk about that because writing here, I'm not querying to write and I am guaranteed
‫that this idea is always going to be unique.
‫Right.
‫I'm not quitting the database to check if it exists or not.
‫The database I'm only writing.
‫So writing is absolutely fast.
‫And every time I write something, I'm going to always get a new idea.
‫Right.
‫So I don't really need to query how awesome is this.
‫Right.
‫Immediately get an idea every time, whether it's a billion row, whether it's three billion or trillion
‫rights is going to be fast because right at the end.
‫Now, if you want to get a little bit technical here, this database, if it's a battery right based
‫database like the engine, the storage engine is arbitrary, then rights are going to get slower and
‫slower the larger you get because this index is arbitrary index.
‫And as you guys know, with B 3s, we try to balance those trees.
‫Right.
‫And I'm going to make a video about butcheries maybe.
‫And as I start writing right.
‫And running those, Beatriz's was going to be get slower to rebalance because we need to reshuffle the
‫trees and move the data structures around.
‫So Ryan is going to be slower the more data you have.
‫But if you're using an entry, right.
‫Like Cassandra, Cassandra is not an author.
‫Well, let's let's take north equal out of the equation.
‫Let's say you're using rocks, DB and mythical persona, for example, rocks, DB or my rocks.
‫Right.
‫So my skull can be configured with an LSM engine and element in this case is going to be the best because
‫writing is going to be so fast.
‫Now let's jump into I think we talked about the you are we talk about the table design, we talk about
‫the querying here and looks good.
‫This isn't I'm not interested in any caching or anything.
‫Guys, you can use caching, but let's just make it simple.
‫This code is going to be so short, right.
‫That the code to generate that and I'm going to show you the code as well.
‫Hopefully, I don't know if I'm going to do go through the code was the code is really easy to write
‫here.
‫Right.
‫So that's the first design.
‫Is this perfect?
‫Absolutely not.
‫Because Hosain, I don't like this, but slash seven is as large as larger because it's very predictable.
‫Right.
‫That predictable design is going to you can predict the next you are very simply.
‫And that's not a good idea for hackers.
‫Like if you if you give don't ever get about attacker the the clue.
‫Of this incremental, predictable ideas, because they can do bad things with this, right, but if
‫you don't really care, right, and they use those like these these stories are public anyway.
‫Right.
‫That's OK, but what they can do is essentially they can scan your database, right, because they can
‫just write a code to loop through all the ideas from one to one billion and they can retrieve all the
‫URLs.
‫I don't know why they're going to do that, but they can.
‫So the predictability is July four attack is back.
‫So some people don't like this.
‫I am absolutely fine with it sometimes, especially with the benefits that gives us like this is give
‫us extreme Goodreads and extreme good rights as well.
‫Right reads are good and writes the are good as well.
‫Isn't that fantastic.
‫Right.
‫Let's change the color back to what?
‫All right, so that's why we wanted to do.
‫Isn't that awesome, guys?
‫So that's the first design that numbers design get.
‫The pros, we talk about pros very fast, write and read, but the cons is the predictability, right?
‫And also that no customer Yoro there is no customer your own this stuff.
‫There's no ideas like, oh, give me I want you all to say, oh, this is a Kindle, Amazon, whatever
‫this is.
‫Amazon is the Amazon one, right?
‫Oh, this is my presentation for the executives.
‫You're going to do custom murals if you don't want to do that, if you want to support you, all this
‫design is yours, right?
‫So how about we jump in to another design?
‫Let's clear out this mess guy last year.
‫See, how about that?
‫We're clean, guys.
‫We're clean.
‫We're back.
‫All right.
‫So design.
‫No.
‫Two, which is what what are we designing here?
‫We are designing a system to support custom murals in this case.
‫Right, and and also, we don't want we don't like this, you are cells that start with numbers because
‫I don't want to give the attackers ideas of that predictability.
‫Right.
‫But they have original design is good for like automated Twitter.
‫You are of that.
‫The only system will also generate these.
‫You are ill and store them in that way and the user will never actually see them short.
‫They are always going to see them long.
‫So you can use that original design if the user is not going to see those.
‫Right.
‫But it's absolutely beneficial.
‫Right, Sister?
‫Number two is I want to support customer.
‫So that means if I want to post right on a post here, I make a post request and then slash the zero.
‫And then I want to also specify the customer Yooralla look.
‫So yeah, I want to specify the customer and the customer equal whatever ABC.
‫Right.
‫So I want to specify how the you are ill will be stored in short form.
‫Right.
‫So this is a post request.
‫Well, how are we going to do this?
‫All right.
‫Let's think of the table design.
‫How are we going to store this thing?
‫Well, in this case, I still need the oil, the actual long URL, and there is no escape.
‫We need the short euro as euro.
‫Right.
‫That's how is going to look like, OK, and I'm not sure we're going to need a prime primary queue will
‫come to that.
‫But these are the two columns in this case, right?
‫So now if I come in with a you are ill and I want to post I mean, I want to write, I want to generally
‫take that you are a long YORO and make it into a short URL.
‫So what are you going to do?
‫So many ideas.
‫The first that comes when I decide to hash it right and generate know 256 byte or which is like an equal
‫to 32 by Trie, which is usually or character.
‫Right.
‫And then take for example, the first eight characters, if you want just an eight fixed eight byte
‫characters and you can do a base64.
‫Right.
‫So they look like these YouTube URLs.
‫Right.
‫Which is like let me show you.
‫So this is how best 64 yards look like guys, right?
‫It's characters from A lowercase to Z lowercase from a capital to Z capital, and then all the numbers
‫and plus signs and all that garbage.
‫So that's how base64 and you only use this much, but it can serve them forever.
‫Really it can give them a lot of characters.
‫Right.
‫So yeah.
‫Let's just enjoy and have fun guys doing this stuff.
‫So are we going to start eight characters.
‫Right.
‫So eight bytes take the first eight by then make them into base64.
‫So that's the character.
‫So we're starting a.
‫Technically, eight by three, right?
‫And just like A, B, C, whatever, and this is the long euro gap, and technically what I want to
‫do here is I'm going to make this into last year was another color.
‫I'm going to make this into a primary key.
‫Right.
‫So I want to prevent multiple same orals from getting Cleide because now and the previous design, you
‫don't have collision, you will never have collision.
‫The problem of collision doesn't exist.
‫Right.
‫But here now you have the problem of collision because now you're showing hashing and you're getting
‫taking a huge string and making the smaller string, which is the idea of collision always exists.
‫So.
‫Two ways of solving this problem.
‫OK, take the post request, do this operation, give that eight characters and attempt to immediately
‫insert in the database.
‫Just insert, OK, don't query because it's expensive.
‫You insert and the database will take care of this.
‫If the insult was successful, you're going to get a nice short URL, right?
‫We're going to get that, obviously, you know, the shortfall in this case, unlike that first design,
‫which we only go in the number, and then you will get a return back the oil for you if that failed.
‫Right.
‫Because it can fail.
‫Right.
‫The insects can fail because of the duplicate Primerica, then the observer here is responsible of regenerating
‫a brand new one.
‫And how do you knew that, guys?
‫Right.
‫How do you generate a new one?
‫I just use the oil and unshowered and took the base64 and I'm going if I regenerate it, I'm going to
‫get the same one.
‫So you need the idea of salting here, right?
‫So that's one way of solving it.
‫So you generate a random so-called.
‫And inserted to the shore and then generate a brand new base64, take the first eight characters and
‫write it down, but the moment you do that, you really do you really need to store the salt.
‫I'm not sure we'll think about it.
‫So I didn't really think all of this through.
‫And I'm prepared to best design for you.
‫I'm just walking through your shoes and doing it as if it's the first time.
‫And I wanted to explore everything.
‫That's the fun of this.
‫Your shortener is or any system designed as a fun activity.
‫I want you to have fun.
‫So let's say I'm not going to store the salt because do we really need to.
‫I'm not sure.
‫Right.
‫So I'm going to store it and then, yeah, we now have a brand new euro, short euro, and then I'm
‫now returning that short euro to the user.
‫So there are there could be let's change the color a little bit here and to green and there could be
‫some sort of a feedback loop here.
‫Right.
‫Going back and forth, back and forth, back and forth, because I'll try.
‫Got a collision because it failed.
‫I'm going to try again.
‫Failed.
‫I'm going to try again fail.
‫I'm going to try again.
‫Failed.
‫OK, you got the idea.
‫So there could be a failure here, but you're relying on the database to give you the failure.
‫It's very fast because there's a primary key and it's obviously indexed.
‫Right.
‫So you can you can have this loop of failure.
‫And this could take a long time to resolve if you have if you have a bad, solid algorithm, essentially.
‫But that's another idea.
‫And now you can just take that.
‫You can also take that to you.
‫All right.
‫So that's the idea of case of I do not want I want a random short URL.
‫But if you want to take the users and put your URL and they use this as a euro, that's easy, right?
‫You just inserted it.
‫You try to attempt to answer it.
‫If it exists, you're going to get an error.
‫And you in that particular case, you need to return the error.
‫To the user, right, because this user, this you supplied a custom, Yoro, and that is already exist.
‫But in case if the user did not specify that you don't want to add or write so you could just became
‫more complicated just because you want to support this custom YORO thingy, is it worth it?
‫Maybe, yes.
‫Saying I'm sorry, but I need to do this.
‫I need to support custom.
‫You also you have to pay the price of this loop.
‫You have to pay the price of this branching of the code or the custom.
‫You all return on it or else do this right.
‫So there is like a lot of stuff happening here.
‫Plus your primary key index is now bigger guys, right?
‫I mean, nobody cares about storage these days, but how big it really it is.
‫But now it's a body.
‫You can do the math, but your index is larger.
‫Now your right is going to be slower because it's a strength versus it's a bite, for God's sake, versus
‫64 bit.
‫Well, the orbit, is it big, but integers versus strings.
‫Yeah, and this is the same same index.
‫So I apologize for that.
‫But yeah.
‫It's a character versus.
‫Strength versus just numbers.
‫But now it's a better design, isn't it?
‫Right.
‫I have characters, I have just random Strang's, and instead of just predictable numbers that users
‫can scan my database, I don't want them to scan my database to get all the URLs right.
‫So this is obviously better.
‫What do you guys think?
‫Let me on the comment section, you might say, hey, the first design is good and the second design
‫is, yeah, I know what it is.
‫They know the first design definitely does not work in the second design is better, you might say,
‫Hosain, both designs suck.
‫Here is a better way of doing it.
‫And I would love to hear those.
‫That's why we are here.
‫This is a canvas of artist.
‫You is you is English.
‫You are an artist.
‫Paint guys just paint.
‫Enjoy this process.
‫Don't take things seriously.
‫We're all going to die eventually.
‫So, OK, this is going to get dark.
‫OK, so that's enjoy this process.
‫All right.
‫Definitely faster.
‫It's a good process.
‫Good.
‫So that's the two designs.
‫And now I'm supporting custom Jarrell's with this.
‫Right.
‫And I only needed two fields.
‫Do you need another fields man.
‫All right guys, how about we go through a redo operation.
‫Right since we went right.
‫Let's do a read.
‫This thing is painful guys by the way, just deleting, clearing things.
‫If you have a book, a better way of doing sketching online, let me know in the comments section.
‫Right.
‫I'm I'm struggling around here.
‫So let's write our table again.
‫We have the.
‫All right.
‫We have the short Yahel, which is this eight byte thingy.
‫Right.
‫And that's our table.
‫I think that's the only thing we need to store.
‫And let's walk through this.
‫I want to make a get request here.
‫And this is my Shote.
‫I'm reading those URLs now and this Myanma, my short, your Amazon.
‫Right.
‫And then we take that character.
‫We take this string and we query the database.
‫Right.
‫Let's bless obviously, guys, we need to do as much sanitation as possible to not like because someone
‫was like Amazon, a second injection.
‫Well, the McAllen draw table.
‫You what else they can do that and screw the whole database, so sanitize your input and it's easier
‫than ever.
‫Check out my videos on sexual injections and sanitation and all that jazz.
‫So, yeah, we all to do a select statement here, guys, where the blah, blah, blah equal Amazon.
‫And then we're going to immediately query that.
‫Right.
‫And that's fast because there is an index here, right?
‫We built an index.
‫So so now this huge one billion rose is now smaller, but still good.
‫I mean, people can do sharding and all that stuff, but I really recommend you not to unless your system
‫is big enough to really need sharding.
‫And I talked about when to shorten, when not to show or check out the videos there.
‫But I'm going to query that if I find it, I'm going to return that actual URL, which is this guy.
‫Right.
‫And then I'm going to return it to the user.
‫And by return, I mean literally just do a three or one was three directory one or three or two and
‫do a location equal that.
‫So in order to immediately redirect that stuff.
‫Right.
‫So maybe another video, I'm going to actually sit down.
‫I actually do that code for you.
‫I just want to make the video real short.
‫I don't want to make the video long.
‫You all shot the design we give to designs.
‫And now I want you to just while walking through the scenarios, what else can we do?
‫Can we use nautical databases?
‫Definitely.
‫Can you use caching?
‫Can you use right is definitely you can do a lot of stuff to optimize this.
‫So what's the process of this design process?
‫Well, I have my beautiful custom URLs and I don't no longer have this scanning problem that Korn's
‫it's 100 percent slower than the first design.
‫Right.
‫At least in the writing process.
‫And you might say, I don't care, Hosain.
‫I don't care about the writing process.
‫And you're absolutely right, because writing how often writing happens compared to reads readers is
‫going to be always more than right.
‫Right.
‫So I always think about that.
‫How many people click on short yardage versus how many people generate shortfalls.
‫Right.
‫Unless your Twitter, if you're if you care about reads writes.
‫Right.
‫Like.
‫Like for Twitter, like every time you go to a tweet and put a long you on a Twitter automatically shortens
‫it.
‫So and Twitter have a lot of rights.
‫Right.
‫So now in this case, you might prefer the first design because you're going to store that in a short
‫manner and you're going to retrieve it also in a short manner.
‫But you're going to show the user always the long years, AZO, that doesn't they don't even know the
‫short you all actually exists.
‫Right.
‫So you might you might first design my work.
‫But if you're building an actual tiny oil custom for the user, bit like this design absolutely works,
‫right.
‫And I did talk about scaling persay across the whole ward for this, right.
‫So let's talk about that a little bit before we in the video.
‫So if I am if I want to scale this design right, let's talk about this a little bit.
‫Scaling.
‫All right.
‫Scaling.
‫Let's talk about scaling for both design one and two.
‫It's the same.
‫I think there's the same problem.
‫Right.
‫So let's talk about the scaling.
‫Right.
‫Because that's what the noncyclical people have against the relational databases that they don't scale.
‫So scaling in this case, what are we going to do, guys?
‫And we can clear all that garbage, we don't really need it, but here's the thing, we will make one
‫master.
‫Database and multiple backup databases.
‫Right, and that's changed.
‫Can I change the color on this stuff?
‫I don't think I can.
‫Huh?
‫Never mind.
‫All right, I can't change that color, but here's the thing, guys.
‫So this thing is going to be.
‫The.
‫Back up and this guy is also going to be a backup.
‫What does that mean, a backup means it's designed just for reeds, right?
‫Because that's what do you want to scale?
‫You want to scale reads, right, and the rights always goes to one single database.
‫So there's one single database in Central America.
‫I don't know, North Virginia.
‫Right.
‫And there is a process that pushes.
‫That writes to these reader replicas, and this is called the application, the idea for replication
‫application, and this is like any relational database supports this by default.
‫So now you can scale those guys, right?
‫That Web servers definitely can be scaled.
‫Right.
‫You can put it observer here, but another observer right here and you can point read so you can absolutely
‫point reads.
‫When I say reads, I get requests, right.
‫Hey, give me this URL to this point.
‫Reads to this.
‫Right, and point post request to the server.
‫This is the master or whatever, right?
‫And this is the post requests and post, of course.
‫I mean, what I mean, actual rights of short periods.
‫Right.
‫So you always configure your system to have this wreathes and you configure it to have rights right
‫here, OK?
‫So this kind of scale very easily, right?
‫Because you you remove the reeds and now you associated this only with the rights.
‫Correct.
‫So now this guy that all the reeds can go to this server and all the rest can go to the server and you
‫can do this all day.
‫Right.
‫You can do this like if you're in the U.S., you can do this or the West and this guy is the east.
‫Right.
‫And reading is going to be fine.
‫Right.
‫Only there will be some sort of an eventual consistency even.
‫Yes, guys.
‫Eventual consistency can happen in relational databases, not only not equal, but I am guaranteed that
‫my rights are always consistent here.
‫But there will be a lag where if I write something right and at the same time I try to read it is going
‫to be a lag.
‫Right.
‫So sometimes you want this guy to always accept reads as well.
‫If they are, they're coming from the same IP address.
‫But that's a detail that you can finesse, guys.
‫So that's a replication idea.
‫You might say, Hosain, that's impossible.
‫One database cannot handle all of this stuff.
‫Well, that's absolutely fine as well.
‫You can now, if your rights can no longer scale, then you can go play with the idea of sharding,
‫which we discussed right here.
‫Go check the video so you can share this database only if you absolutely cannot handle the rights guys.
‫Again, you got to really be careful when do you want to share it?
‫Because it's a very complex operation and you can use my Esequiel, you can use the Oracle Oracle so
‫expensive he can use MySQL, Postgres, all those relational beautiful databases.
‫You can also use no SQL databases, but.
‫I don't I do not like the eventual consistency in my no equal databases, especially with rights, that's
‫just personal opinion because I prefer to have consistent rights, even in a single instance, but that
‫databases don't even give you that.
‫No school that doesn't give you that, unfortunately.
‫No, I think I'll take that back.
‫So, yeah, you can replicate this with a Mongo TV, right?
‫With rights, your rights is going to be passed.
‫But it really depends on how you're storing this information.
‫The indexing or not equal databases.
‫I don't know anything about.
‫No, no.
‫I know very little, so I cannot.
‫Possibly tell you to use no sequel database like Mongul, if I don't actually understand the underlining
‫functionality, right.
‫I know that not all not equal support indexes, which is something I just don't like.
‫Right.
‫If you don't support indexing, that's just a big no for me.
‫Right.
‫I need an index so I can quickly query my stuff.
‫Right.
‫I need things that are predictable and that's just mean.
‫Guys, don't let my opinion force you at all, right?
‫Just I want just wants to understand different thing.
‫I'm open to different opinions.
‫Right.
‫So this is an idea of scaling.
‫What did I say wrong?
‫What did I say?
‫Right.
‫And by the way, guys, I forgot to mention something very critical here.
‫There will be a bad ass proxy right here.
‫Oh, how about that?
‫We do have a proxy.
‫Nice.
‫All of this stuff, we've got to be done with a reverse proxy.
‫Right.
‫That could be loaded, balanced.
‫Right.
‫To these master services.
‫Right.
‫So technically, all of that stuff.
‫Right.
‫All of these requests are going through the proxy first is going through the proxy and the proxy decides,
‫hey, go here, go here or go here.
‫Right.
‫So that's the reverse proxy.
‫Right.
‫And you can make unlimited copy of those.
‫Reverse proxy's, right, that reverse proxy, not acts, doesn't only act like a load balancer, purely
‫a load balancer and just do the funnel the request to all of them.
‫No, it actually looks at the data.
‫So it's probably a layer seven load balancer here.
‫And it looks at the data says, oh, this is a get request.
‫I'll take you here.
‫Well, this is a post request.
‫Of course, definitely have to be here.
‫Right.
‫But get request has to go here and has to go to the server.
‫Right.
‫And probably there is a reverse proxy in NE near to each data center like in China, probably going
‫to have one in Asia and now in Central America and probably in Europe and each one take it to the nearest
‫server and maybe the master server is going to set in America.
‫Right.
‫So, yeah, obviously it's going to be slow for scaling purposes, but maybe you don't really care about
‫rights much.
‫Right.
‫But now comes to the sharding.
‫Hey, I'm going to share my database.
‫I'm going to put a shard in Europe so rights are going to be faster.
‫All about trade off, guys.
‫It's all about real guys.
‫I think that's going to stop here.
‫What do you what do you guys think?
‫Did you like this episode?
‫How did you like this interaction of the spend thingee.
‫Obviously like it.
‫Give me your opinion.
‫Give me any critique that you might have in the comments section below, because I love to be better
‫and do better with you guys.
‫Right.
‫And then let's have a discussion.
‫Why do you guys think is the better way of doing things right?
‫Everything has a pros and cons.
‫It's Gumbs comes back to simplicity.
‫Simplicity, sometimes rules and maybe simple thing can create the best design, really, while having
‫complexity can having complex design leads to complex implementation, which leads to the things that
‫we all hate.
‫Bugs.
‫We hate bugs, guys.
‫So simple design needs a simple, elegant implementation with code.
‫And then once you have a simple implementation, you have a rigid, rigid, you have a solid, bad ass
‫system.
‫And you when you have a bad system, you are unstopped, unstoppable.
‫Guisewite So paint guys sit down and paint.
‫What do you guys think?
‫If you know where to start, start somewhere, write something, write anything that comes to your head,
‫OK?
‫And that's why when I, when I talk about back in engineering and systems, I need you to understand
‫how databases work.
‫I need you to understand how observers work.
‫So read, read, read, read, read, keep consuming, learn and learn and learn.
‫Because we are all learning guys here.
‫I want to know we're not going to stop learning.
‫Are our guys going to leave you here?
‫See.
‫And the next one leave.
‫I like subscribe and I'm going to see you in the next one.
‫You guys say awesome.