I watched 4 different Tiny URL System Design Video. This one is by far the best
@aakashgq2 жыл бұрын
I read many different ways this can be designed. But this design looks the best of all as it is highly scalable, very efficient and something that can easily work on a global scale. Thanks Sandeep for so much of hard work at your end to come up with such wonderful designs. I am watching your entire playlist.
@aman1893_2 жыл бұрын
Hey do you want to study system design together? I have a lot of exp but I feel most of the online resources are incorrect or incomplete. We can make a solid understanding of the common designs in next 10-15 days by brainstorming everything together.
@rahular4596 Жыл бұрын
@@aman1893_ I would be happy to learn from you😀
@ersinerdem72853 жыл бұрын
There is another approach which pre-calculates the short urls, and use when requested. This way, there will not be range loses when servers go down. Your way is also very good, thank you!
@anonymousgod2006 Жыл бұрын
Ya I think if Token Service layer is removed and Url shortener service simply do what Token service is doing, that will be your case, and it seems fine to me
@alianwar28572 жыл бұрын
Very informative and the way you show the simple way to design first and then discard it again telling the problems and how we could tackle that, is really great.
@vozone104 жыл бұрын
A diagram with Kafka for Analytics would be a cherry on the cake. Overall great job!
@dongiveajack3 жыл бұрын
One of the best video i found out on youtube for url shortening.
@Arjun-tg1go2 жыл бұрын
Just a thought- instead of using the token service we can generate unique tokens per service within the service itself. Steps could be as follows 1. When service node starts, it will registers itself with DB and gets itself an ID and it’s sequence will start with 1 2. Now, a particular node can generate token based on its ID+Today’s date+sequence 3.When a particular node goes down, new node will spin up and performs step 1 4. This will avoid complexity of calling token service totally
@alpitanand20 Жыл бұрын
You are talking about Zookeeper here.
@Arjun-tg1go Жыл бұрын
@@alpitanand20 use anything (db/zk) that is a singleton service.
@KingKingSofa Жыл бұрын
MD5 Hash of the user IP Address + Time Stamp encoded to base 62 would also be valid. Both these approaches save us from the complexity of managing another set of services and their connections to a DB. We can more easily scale horizontally.
@bablushaw68562 жыл бұрын
I had this video in watch recommendation but always skipping it thinking shortening URL, how hard it could be. But going through this video I started realize nothing is easy at scale. Your way of explaining is so awesome that at the same time I understood depth of problem and its solutions. Please keep it up.
@theSeniorSDE3 жыл бұрын
It would be great if you build up slowly for the tech/tool to pick up for the design rather than directly putting the cassandra or redis or kafka. There can be possibility that the Interviewer is highly good at those tools and will start digging deep into that as soon as we name a stack which can surely bring us in trouble sometimes.
@debasish23322 жыл бұрын
Which make sense
@AlbertoRodriguez-oe6jo2 жыл бұрын
As an alternative, you can read about the tool being discussed in video after watching it. It will keep the videos shorter and packed with more relevant content.
@isachinq2 жыл бұрын
Isn't a token service a single point of failure? Even if we use multiple token service, how will we synchronise all of them? Please answer 🙏
@ANILKHANDEI2 жыл бұрын
@@isachinq i think the token service is being load balanced to avoid a single point of failure. Having miltiple tokenservices will not impact the design as it is only used to get the next range from same mysql cluster.
@isachinq2 жыл бұрын
@@ANILKHANDEI how will you synchronise all the MySQL in MySQL cluster? By definition, horizontal scaling will bring down the consistency
@prashantsingh-yx4yh3 жыл бұрын
What a calm and composed thoughts/teaching for each and everything Hate off bhai...one of the best tech youTubers!!!
@manojkp803 жыл бұрын
Great video, as always very helpful. If you could 1) add custom key support - user can specify their own tiny url 2) talk more about what could be other ways like, md5(main url) -> base2_encode, and their drawbacks etc 3) add diagram on a analytics part, that would really be helpful. Do you also feel a cache can be added in front of Cassandra to serve hot urls? Thanks, keep helping.
@annafalvello81382 жыл бұрын
"in technical terms it's called a collision, but for us it's a problem" made me laugh. thanks for the great content
@ramyasreetejo2 ай бұрын
best video out of all available resources for a url shortening service
@duzgunkenan6 ай бұрын
great energy, honest intention, a beatiful human being. thank you
@sharadkumar38233 жыл бұрын
Even after 1 year this material is gold !
@jasper5016 Жыл бұрын
Bhai thanks so much. I got your course on Udemy as well. There is not better channel than this on System Design.
@VibeWithSingh3 жыл бұрын
Great video. Thanks for putting all the effort and explaining different choices and corresponding trade offs. 👍
@g_pazzini11 ай бұрын
wow.. you are a world class system architect
@earthpligrim57572 жыл бұрын
this is the first video im waching on your channel and i just loved the explanation. im sure its gonna help me with my interivew. the very first thing i did post watching the video is subscribing. thanks alot for the detailed information.
@AlbertoRodriguez-oe6jo2 жыл бұрын
You're highly articulate, I love that.
@chaitanyawaikar3824 жыл бұрын
Excellent explanation !!! Even though there are a bunch of system design videos out there, your videos stand apart from them by discussing various situations and pitfalls of using a certain tool/ database. Just one quick suggestion from my side regarding upcoming videos - can you please create any video that explains capacity estimation of a database. For example how much space will a users table with let's say 6 attributes having almost 100 million records take is postgres or mongodb or any other database. This is also commonly asked in interviews now a days and given your breadth of experience, I think you would be able to create awesome content in this space also. Once again Thanks for videos :)
@codeKarle4 жыл бұрын
Thanks Chaitanya! We'll put this in some smaller video that comes out in the future. Just that it's a time taking thing to go over the calculations so we skipped it in all the videos till now :)
@roshanpatro57778 күн бұрын
Such an amazing effort, man! Thank you so so much. 🙏❤
@AnshumanDwivedi59883 жыл бұрын
One the best I have seen so far on this topic. Keep making videos on systems design. I just subscribed and tunned in for every upcoming video now. 👍🎉💐
@gowsank2 жыл бұрын
Love it!! Thanks for sharing multiple options of implementing a solution. Keep posting more videos
@Legendary-Akshit4 жыл бұрын
Amazing video with possibly the best explanation so far on this use case. I had watched several videos on TinyURL but none could explain in the first 5 mins so lucidly the need for 7 characters based shortened URL. Good job
@isachinq2 жыл бұрын
Isn't a token service a single point of failure? Even if we use multiple token service, how will we synchronise all of them? Please answer 🙏
@mirrorps2 жыл бұрын
@@isachinq Sandeep already answered your question in the video and it's a common approach to scaling mysql - the token service (by default) will be not overloaded with massive amount of requests, but if somehow it is then the solution would be to utilise the MySql horizontal scaling / sharding between multiple servers / instances.
@isachinq2 жыл бұрын
@@mirrorps but horizontal scaling won't ensure the consistency between different MySQL nodes. So it may assign the same range of values
@mirrorps2 жыл бұрын
@@isachinq there are some hashing algos to distribute the data between the nodes, so the ranges may be based on similar hashing algorithms
@rishikeshmpawar2 жыл бұрын
Really cool content. Analytics/Observability is generally mised; thanks for taling about it. Provided html page link in description for the content would definitely help to revise.
@deepanshunagpal7587 Жыл бұрын
One issue is that sequentially generating shortcode could be security threat as it would be predictable either we should append a random number at starting or end before converting base 62 conversion
@foodfan45124 жыл бұрын
Amazing explanation! Can you please provide pdf or image format of the architecture like you provided for other videos? It really helps to see everything all together in 1 place to digest everything. Thank you.
@codeKarle4 жыл бұрын
Sure, we'll get it done in a few days :)
@samirhere43414 жыл бұрын
Was looking for the same. Thank you
@codeKarle4 жыл бұрын
There you go: www.codekarle.com/system-design/TinyUrl-system-design.html You'll find the architecture & summary here :)
@poojabennabhaktula48834 ай бұрын
Awesome explantation , Please keep Posting more videos.
@domicio1577 Жыл бұрын
Awesome video! Lots of insights. As a piece of feedback, I would change microphones. Thank you.
@hanspeterpfister22534 жыл бұрын
Great work. Can you also upload a video for Dropbox/Google Drive like service? In case of Dropbox, most videos drop the ball at, there will be a Notification service and it will communicate with clients asynchronously using Queues and every client will have its own Queue. They don't talk about, if there are billions of clients, do we expect to have a billion queues? Is that scalable? Do focus on this as well if you make the video.
@codeKarle4 жыл бұрын
Sure, we'll try to make that in a few weeks
@darshanpandya89783 жыл бұрын
all the video you have made are awesome and really easy to understand. If you can make more videos regarding technologies that being used in system design. Having more deeper dive and comparison of difference tech is helpful.
@rakshashanbhag27233 ай бұрын
This is amazing! But quick question, isn't the token service also a single point of failure?
@sergiim56012 жыл бұрын
Thanks, amazing explanation of TinyURL system design !
@sankarsattari59212 жыл бұрын
I think there is still a possibility of duplicates because we are using a substring of length 6 or 7 of the base62 encoding of the numbers, which can collide. for example base62(0000001) is 107Zzj5ex0 and base62(0000002) is 107Zzj5ex0 as you can see the prefixes are the same.
@sagardafle2 жыл бұрын
Hey, how is base62(0000001) = 107Zzj5ex0?
@MegaBelltone Жыл бұрын
@@sagardafle Doesn't matter. The thing is that there is always possibility of collision if we do substring. I can't find any explanation of it anywhere, as how to resolve.
@foodfan45124 жыл бұрын
Amazing clear content!! Can you please help me with the following questions: 1. How are spam and malicious links handled? 2. How might we be able to track and display traffic stats to users?
@codeKarle4 жыл бұрын
Thanks! For Spam and Malicious content, I'll be doing another video. That's a fairly complex system in itself. Tracking I have covered as part of this video, and once it is tracked it can be shown in the same UI where we show all the Short URLs that the user has created.
@godolsss21394 жыл бұрын
Keep posting..love your vids...very simple and understandable content...
@codeKarle4 жыл бұрын
Glad you like them :)
@ashokkumarmaniraj12503 жыл бұрын
Great Job Sandeep!!! I have seen all your system design videos. Waiting to see a video on cloud system design.
@weightwatcher2214 жыл бұрын
1 of the best system design video. Might not be reasonable question but possible. How do we scale it to some arbitrary large(billion) of txns per day?
@codeKarle4 жыл бұрын
Thanks!! I believe that with this exact same architecture, you can scale it to not just billions, but potentially even trillions of transactions per day. All you need to change is - Modify the range of token service to now return a larger range thereby reducing the hits on token service, increase the length of the short URL, serve this service out of even more Data centers that are spread across the globe based on your traffic patterns, and throw in more hardware.
@weightwatcher2214 жыл бұрын
@@codeKarle thank you for the quick response
@andreadiotallevi5780 Жыл бұрын
Excellent presentation skills!! Thank you
@p111calcutta1 Жыл бұрын
@codeKarle how do you handle the case when token service goes down and we wait for data to persist in sql db before token service return the ranges to short url service ? what if sql db goes down ? if we keep replica of db then do we want data to be synced before we return range to user ?
@chiragkothari2782 жыл бұрын
Nice video. I think there can be another functional requirement of payment option for number of times a url gets used. Also we should have. a rate limiting also.
@nikitasinghchauhan62394 жыл бұрын
You explained so well. nice video .
@codeKarle4 жыл бұрын
Thanks a lot 😊
@SAK-y6jАй бұрын
Thanks, very insightful
@yogaranjansingh5043 жыл бұрын
please create more system design videos, love your work
@seelamrameshreddy7022 жыл бұрын
It is really nice video. I have couple questions. 1. Is duplicates URLs would be stored in DB every time when we hit a request ? 2. Why would you consider caching during GET ?
@ambikabc3 жыл бұрын
I have a doubt here.. You said that if we have multiple redis then it will be tricky but then you added more redis so I kind of got lost there or may be I dint get what you said... Can you please elobarate?
@Uppathebest7 ай бұрын
great explanation Karle. Pity you stopped making videos! If you resume, you may want to invest in a better microphone for the benefit of your viewers :)
@SaikrishnaA-b4c8 ай бұрын
Are you going to maintain the mappings from counter range to its availability in an extra datastore, or a table so that your token service could handle them?
@bowang18254 жыл бұрын
Very good way to handle token service. Finished all your video, when do you plan to have new videos?
@codeKarle4 жыл бұрын
Thanks!! A bit busy with work these days, soon there would be more videos coming. Do share these in your circle if you liked them :)
@hokayantra_4 жыл бұрын
Custom shorlink support is also most of the user wants plus its not good to have incremental shorlink ... better to have something randomized nature of shortlink.. share your thoughts
@codeKarle4 жыл бұрын
Custom Shortlink is a good feature, that can be implemented easily I believe. You are right about the incremental shortlinks, that's a trade-off you need to choose. Random is good, but you'll end up in high collisions and higher latencies. If the NFR's are okay with some high latency/less throughput, then a randomized solution would be a much better choice since it's hard to predict the next short URL.
@anandratn83394 жыл бұрын
@@codeKarle another possibility is to add salt in the incremented number being used by shortener service that will maintain the uniqueness as well as hard to guess
@maheshnavani52942 жыл бұрын
Great Video, would appreciate if you can do 1. Elevator System 2. Discount System at SuperMart
@arghyasen96826 ай бұрын
One question - Whenever the user asks for a short URL do we check in the DB if there is an existing short url for the same? If so, will that not again slow down the application?
@srinivasanvk573 жыл бұрын
Great job on your side. A big thank you from my end. Can you please answer the query on handling duplicate requests? Same URL requested 3 times generates 3 tinyURL? How to handle it in this design?
@srinivasanvk573 жыл бұрын
Ok I just verified in bitly and found that they generate different short URL everytime the same long URL is passed. So this is not a concern apparently. Thanks anyways
@LifeWithSeb997 ай бұрын
How can you request a number from Redis Cluster? Isn't that just a in-memory database? Would you need to program some kind of a logic into redis cluster?
@andreadiotallevi5780 Жыл бұрын
Great video! I have just one question. For the short url service to be able to keep track of the current range, does it need to be stateful? And how / where would you store that info?
@vidhanchandra39973 жыл бұрын
Crystal clear explanation.......
@rohitrangera87662 жыл бұрын
Awesome video, can you share system design on Voting Machine (EVM)?
@vivekgujari91185 күн бұрын
good explanation.
@jdr3808 Жыл бұрын
Thanks, I have seen many solutions talking about Event based decoupled systems. However I never encountered a robust way of making sure there is no Consistency and Integrity being effected due to any failures during those Async processing of the Event. What are various techniques for ensure Decoupled systems ensures no loss
@akfsx2 жыл бұрын
It's also possible to use distributed RNG (another topic for SD interview) or just hash long URLs with extra steps for hash collisions.
@luqmansen3 жыл бұрын
Very well explained, except you can get better microphone, that would be great, many thanks
@mehrdadshademan18732 жыл бұрын
what are the tables rows contains information you keep in the cassandra?
@ujjwaldave8646 Жыл бұрын
You could have given some more thought on the short url to long url flow. Fetching data from Cassandra for each and every request could be very time consuming an latency needs may not be met. May be we can use caching in that flow to reduce the fetch latency.
@kritikajain66776 ай бұрын
Let's say we have scenarios where one url U1, is called from two different users for the first time, and both the request R1 and R2 come at the same time, but being sent to different nodes, since all the server nodes have different range of tokens being given to them, same url will be using two tokens, it can also result in decreasing the amount of tokens we have?
@midhunthomson41359 ай бұрын
Very informative. Thankyou!
@neerajramachandran46475 ай бұрын
Does this approach assume that we do not care about idempotency? In this model, if the long to short URL service receives multiple requests of the same long URL, the token service will assign that request to different short URLs.
@gauravradioactive5 ай бұрын
Thank you for the great content ! It looks like the Token Service is a single point of failure as well. And if we create multiple instances of the Token Service, how do they ensure that each instance provides a unique URL range, and no 2 instances provide overlapping ranges? If the Token Services are supposed to communicate each other before deciding the range for an incoming request, this would again add to overhead and slow down the process. Can someone please share their thoughts on this ?
@PradeepSingh-vm1gl3 жыл бұрын
Maza aa gya bhai. Thank You so much. ❤
@rajgupta30434 жыл бұрын
I am having trouble understanding, that let's say there are two datacenters. Each datacenter has its own token service and DB. How do you make sure that token service in two different data centers don't end up assinging same range to the SHORTTOLONGURL service? I am assuming DB contains the range and token service simply gets the range from DB, and it's an atomic transaction. But how do you manage ranges in DB across data centers? Would you have another service for doing so?
@codeKarle4 жыл бұрын
The main idea of two DCs for token service is for redundancy. Let's say if you have Token Service in DC1 and DC2, the Master of DB can be in DC1 and it can have a Slave in DC2. if Master goes down, or DC1 is not available, then slave in DC2 can become the master, but for all other transactions it can make a cross DC call to the Database in DC1 thus making sure that the range is always unique. Latency is not a concern here because it's once in a few hours kind of an API call to assign tokens.
@A_Aaa8167 ай бұрын
I don't undestand why not redis ? following you concern about Single Point of Failure --> Redis is designed for horizontal scalability and can be deployed in a clustered configuration for high availability and fault tolerance. Can you explain better ?
@yashendragoyal3 жыл бұрын
A small doubt here, let's say we pick n as 6 for short URL chars and we use base 64 instead of 62. If you are starting the range from 1000 to 9999, then the base64 encoding will contain 6 chars, but as soon as you move to 10000 the chars will be 7. Doesn't it diverge from the initial design to keep the short URL chars as 6 only, also we are only using 9000 URLs in this range? If we follow this route, we might have to go to a very high range to convert to base64 and create a short URL (which will not be short anymore)
@santoshgupta17452 жыл бұрын
6^64 can contains 6.3340287e+49 unique numbers
@LuveenWadhwani4 ай бұрын
How do you scale the DB for token service across multiple DCs and regions without repeating token ranges? Do the token ranges need to be seeded manually per DC/region to prevent the same range from being reused in more than one DC/region? Does this solution constrain us to using a DB technology like Spanner so there is one consistent data set that spans geographies and is replicated in near real time?
@Bb-cz3fq Жыл бұрын
HI I have a question regarding the Collision it this case is avoided if we have two same shortURL ,because it uses tokens right?
@Sagarvilas2 жыл бұрын
I have heard in many videos that checking in DB if the URL exists is not efficient, I do not understand that, you are designing a system with 1:200 write to read ration, how much of an overhead it is to check the database if the URL exists?
@rohanskoshti2 жыл бұрын
What if token service goes down ? I was unable to see your view on this or why it won't go down ? Thanks for letting me know of it.
@sushantgawade92892 жыл бұрын
Hey is your content available on any other platform ?
@Spiritualleace3 жыл бұрын
Great stuff! Why would the asynchronous request for analytics fail?
@karnveerayush3 жыл бұрын
there can be multiple reasons such as: Network failure, etc.
@codeKarle3 жыл бұрын
It's a good idea to assume everything can fail. Could be any reason, network related, service outage, firewalls, etc. Just that in Async requests, you usually don't bother if it fails, so there it becomes important to keep track of what happens when they fail.
@user-vq6yi7se2r Жыл бұрын
Excellent. Thank you!
@abhinee2 жыл бұрын
how is redis is single point of failure, most cloud providers support HA for redis clusters?
@andriylytvynskyy8359 Жыл бұрын
How we can make sure that we don't "shorten" urls which have already been "shortened" - probably with some cache... otherwise we would need to query Cassandra and find out but is it not a cheap operation?
@hemantagrawal253 жыл бұрын
can we use instance id and utc time to generate token instead of taking separate token generation service and maintain token range as per different instance.
@SantoshSunagar-iv8fb5 ай бұрын
Very informative videos
@chepaiytrath2 жыл бұрын
After encoding the Base10 token to Base62/Base64 for readability, doesn't taking out the first few characters(ex. 7 chars) and using them to store the short URLs increase the collision probability. Basically, from all the token ranges provided to us by token service, we get unique tokens. Cool. Then we convert those Base10 tokens to Base64. Cool. Isn't it possible to get the first 7 characters of two completely different base64 encoded tokens to be the same and thus resulting in a collision. How do you handle this. Similar situation would also arise even if you take the "Encoding URLs" approach
@ashishbhardwaj15462 жыл бұрын
I would rather choose last 6-7 chars. What do you think ? Less probability of having collision
@SchoolScience2 жыл бұрын
@@ashishbhardwaj1546 it still might have collision and we may not prove that in the scale of billions of numbers.
@motivation2change754 Жыл бұрын
Better than paid courses
@integralCalculus2 жыл бұрын
Great video! Regarding scaling the token service, how are we going to keep the state information regarding the next available range of IDs consistent across multiple data centres? I assume the next available range info is going to be maintained in a single record (sort of a sequence number) which now needs to be globally replicated across data centers. At the cost of significant latency, this could be addressed by having the URL service request the range from the token service in a background thread (as the current range on the URL server approaches depletion), so that the token service can then return the next available range ONLY after synchronously replicating the updated record across data centers. Basically we are trying to handle the problem of a globally consistent sequence number. Let me know your thoughts.
@smalldog30012 жыл бұрын
excellent question.. was about to post it but read this. I also like your proposed solution!
@anonymousgod2006 Жыл бұрын
Doesnt the token service simply get an entry with F or T flag corresponding to a range. If there are multiple token service, it will be fine right as its single DB or are you suggesting if we want multiple DBs as well to avoid SPOF and geography based quick responses
@integralCalculus8 ай бұрын
@@anonymousgod2006we could take a hybrid approach. We can have the tokens DB geographically distributed across data centers while the service in a given DC backed by a single DB.We can assign large non overlapping ranges to each data center. So may be 0-1Billion can be assigned to DC1, 1B+1 - 2B to DC2 and so on. And within a DC, we just have multiple nodes in the token service backed by a single DB.
@SR0863 жыл бұрын
Great video. Very well done. However, please don't use X as a variable and also as the symbol for multiplication! That's very confusing and probably would look bad in an interview.
@ManojKumar-bk7bj2 жыл бұрын
Nice explanation!!
@ayushtewari28268 ай бұрын
What if the Token Service Goes down? We cannot have multiple deployments for this service. We want that there should be some body that is a single point of truth, that provides us the next range. But what if it goes down? Any solutions? Or if my question is wrong. Please explain.
@ajaytiwary5798 Жыл бұрын
Token service can also be single point of failure.If we will use multiple instances then again will same issue of duplication.
@devprakash53202 ай бұрын
I learnt a lot
@shubhampandey6683 жыл бұрын
Should not we be using a cache for doing the redirects since it is pretty static data?
@l.oleksandr2 жыл бұрын
Thank you for this information
@Mohamed-uf5jh3 жыл бұрын
excellent video , Thanks sir
@Zaika962 жыл бұрын
nicely expained
@akagragupta99687 ай бұрын
If I generate multiple instances of token service it can also send same range to multiple services....?
@amitagrawal46602 жыл бұрын
Why two different cassandra DB is used.. one for Long to short url request and other short to long url ? How will the second DB get those information via replication?
@riteshsrivastava72272 жыл бұрын
I love your videos buddy...
@sameerforyou012 жыл бұрын
Please make some video on real life multithreading application architecture