System Design Interview Question: Design URL Shortener

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 มิ.ย. 2024
  • Designing a scalable and secure URL shortener service like TinyURL or Bitly, planning the system architecture, API design, and key strategies for high availability and security.
    Free Web Developers Community and Courses: www.skool.com/web-dev-mastery
    • System Design Interview
    🔖 Sections
    0:00 Introduction
    0:53 Functional and Non-functional Requirements
    1:18 Clarifying Questions
    2:30 Data Estimation
    4:36 High-Level System Design
    5:24 API Design
    7:13 Database: Storing the shortened URLs
    8:18 URL Shortener Service
    10:19 High Availability & Low Latency
    11:20 Database Scaling
    12:24 Security Considerations
    #systemdesigninterview #designtinyurl #designurlshortener

ความคิดเห็น • 15

  • @Coding101-nb5ej
    @Coding101-nb5ej 3 หลายเดือนก่อน +4

    I feel like I should have paid for this level of insights. thank you so much for sharing

    • @hayk.simonyan
      @hayk.simonyan  3 หลายเดือนก่อน

      Glad to hear that

  • @kzrfaisal
    @kzrfaisal 3 หลายเดือนก่อน +2

    Wooahh....I have watched so many videos on this topic but always loose it in the middle of the video, but you made me stick to the end, the amount of simplicity you brought in system design explanation is commendable. We really need more of these 🙌. THANKS A LOT.

    • @hayk.simonyan
      @hayk.simonyan  3 หลายเดือนก่อน

      Great to hear that!! Expect many more

  • @vijayansivaraman7923
    @vijayansivaraman7923 3 หลายเดือนก่อน +3

    @Hayk Simonyan, In my 13 years of experience in .Net as as full stack developer, So far i didn't see any other channel explaining this much crisp and clear with animation images to understand better. Kudos to your effort and hardwork. Very much Appreciated. I wish you will get more subscribers and will reach great heights. Can you post videos on Angular, Javascript and .Net 7, EFCore , Azure full tutorials with real time examples ?

    • @hayk.simonyan
      @hayk.simonyan  3 หลายเดือนก่อน

      @vijayansivaraman7923 It's great to hear that you're interested in these topics! Expect more tutorials like this here. I'm not an expert in .Net, but I'm planning to post about JS + frontend frameworks (Angular, React) and cloud providers (Azure, etc.) on this channel

  • @Aditya-lc5uk
    @Aditya-lc5uk 3 หลายเดือนก่อน +2

    Damn this is some gold content !! Absolutely loved it !!

  • @passionforsciencel5180
    @passionforsciencel5180 หลายเดือนก่อน +2

    Hey, I stumbled upon a more efficient approach for the initial step of our URL shortener project. Instead of the traditional method involving database creation and random ID insertion to ensure unpredictability, I devised a single script. This script generates IDs synchronously without relying on a database. It's incredibly memory-efficient (no heap allocation) and adept at handling high traffic seamlessly. The secret? Just a simple mathematical concept. Intrigued? Let me know if you want to dive in! 😊

    • @hayk.simonyan
      @hayk.simonyan  หลายเดือนก่อน

      hey, yes creating all keys upfront will be inefficient. A better approach is to start with a database auto-incrementing integer as your unique identifier for each shortened URL. Then encode this integer into a short alphanumeric string (using base62 or similar techniques) for a compact and user-friendly representation

    • @passionforsciencel5180
      @passionforsciencel5180 หลายเดือนก่อน

      @hayk.simonyan,
      I have come across a mathematical concept known as the "Modular Inverse" that could revolutionize the approach to URL shortening, eliminating the need for a database entirely:
      First, select a large prime number, denoted as 'm', ideally the nearest prime number to the anticipated number of links to be generated over the lifetime of the application.
      Within your application, initialize a counter, 'i', starting from 2 (1 always return 1) and incrementing up to 'm'.
      For each incoming request, return the modular inverse of 'i' with respect to 'm'. This operation guarantees unpredictability and non-repetitiveness due to the prime nature of 'm'. Increment 'i' by one after each request.
      Here's an example with 'm' set to 37:
      i = 2, result = 19
      i = 3, result = 25
      i = 4, result = 28
      i = 5, result = 37
      i = 6, result = 31
      i = 7, result = 16
      i = 8, result = 14
      i = 9, result = 33
      i = 10, result = 26
      i = 11, result = 27
      i = 12, result = 34
      i = 13, result = 20
      i = 14, result = 8
      i = 15, result = 5
      i = 16, result = 7
      i = 17, result = 34
      i = 18, result = 35
      i = 19, result = 2
      i = 20, result = 13
      i also searched about the time complexity of Modular_Inverse function and i get O(log(min(i,m))) .
      So what you think ?
      Best regards, Bouzid Kobchi

    • @hayk.simonyan
      @hayk.simonyan  หลายเดือนก่อน

      @@passionforsciencel5180 it's a clever approach 👍 For URL shortening systems where the anticipated scale is known, this inverse method might be a great fit. However, for large scale systems where flexibility, unpredictability, and advanced features such as custom short URLs are expected, a traditional database backed method is likely more suitable

    • @passionforsciencel5180
      @passionforsciencel5180 หลายเดือนก่อน +1

      @@hayk.simonyan
      Anyway, i like to mention it , sometimes mathematicians can replace us 😅
      Thanks for your feedback

  • @ntnmnk2009
    @ntnmnk2009 3 หลายเดือนก่อน

    How do you use the two databases, one SQL and another NoSQL? Like what is each database's purpose?

    • @hayk.simonyan
      @hayk.simonyan  3 หลายเดือนก่อน

      Sql database keeps track of the available keys, and Nosql is the primary database that stores the shortened URLs and their metadata