7/11/2023 0 Comments Design tinyurl geeksforgeeks![]() ![]() I probably wouldn't need multiple servers either, one beefy machine might be enough to do the job. If I had the guarantee that my servers never fails, then I wouldn't need Zookeeper. it is resilient to failures).Īnd that's the gist of the problem. But how does Zookeeper do that?įirst of all, why is it so hard to generate a unique sequence? Afterall, I can use a single computer to keep increasing a counter, and that would be unique, right? In fact, that solution is mentioned by Tushar in the video, but later rejected, because the counter-generating server might fail (either the machine itself crashes, or the network might go down etc.), and Zookeeper, somehow, magically provides "high availability" (i.e. Instead of answering the question "how to generate a unique sequence?" (or sequence range, in this case), this solution simply says "I'll just ask Zookeeper to give me one". ![]() The reason I think this answer is unsatisfying is because, while it works, it simply shifts the responsibility of generating the "unique" part of the sequence, which, is the hardest part of the problem, to Zookeeper. If the each server has a unique range, then they are guaranteed to generate unique sequences. Each server would be in assigned only one particular range to work with, and Apache Zookeeper is used to coordinate the sequence range assignments. To summarize, the most sophisticated solution proposed in the video is to partition all possible short sequences into ranges, and use a set of servers to return a monotonically increasing sequence, which falls within a range. That being said, they are sort of unsatisfying. Tushar's proposed solutions are quite good and I think most interviewers would be satisfied with them (please watch the video before continuing to read this post). The main problem is the createShort() API: How do you generate a short sequence of characters that is unique among URLs (note that uniqueness is an important property, we don't want different URLs to have the same shortcut). The second one is easy, you simply need to do a lookup and return the long URL (or 404 if none exists). This video discusses a common developer interview question, namely, how do you design a service like TinyURL, which allows users to turn long URLs into short ones that are just several characters long ( ).īasically, a TinyURL-like service would have 2 main APIs: createShort(longUrl) and getLong(shortUrl). Recently I came across a Youtube video called: System Design : Design a service like TinyUrl, from the channel Tushar Roy - Coding Made Simple. ![]() How would you design a service like TinyURL or Bitly ? ![]()
0 Comments
Leave a Reply. |