System Design - Part 12 | Design a Unique ID Generator | 4 Methods

Поділитися
Вставка
  • Опубліковано 14 січ 2025

КОМЕНТАРІ • 6

  • @charliioo
    @charliioo Місяць тому

    Amazing video thank you !!

  • @AmitKumar-cp1oz
    @AmitKumar-cp1oz Місяць тому

    thanks

  • @nageshnimmala7366
    @nageshnimmala7366 Місяць тому

    Hi @nikoo28 thanks for the info , i have a question can you please clarify this let's say if i want to design a systen like which generate unique id's in multi node cluster (mongo) in this case if parllel requests comes to server i think there will be one master which accept updates , writes so here how the system will handle parllel requests comes to same document either by using atomicity opeartions , at this time mongo db will lock the document or how it handles mongo db provides counter collection as per docs how this handle concurrency

    • @nikoo28
      @nikoo28  Місяць тому +1

      In MongoDB, unique ID generation in a multi-node cluster is handled through atomic operations like `findAndModify()` with document-level locking. When parallel requests occur, MongoDB ensures concurrency by:
      - Locking the specific document during write operations
      - Using atomic increments on a counter collection
      - Preventing race conditions through `$inc` operator
      - Supporting concurrent reads while a document is being updated
      The counter collection provides a thread-safe mechanism to generate sequential, unique IDs across distributed nodes. This mechanism guarantee that even with multiple simultaneous requests, each ID remains unique and consistently generated.​​​​​​​​​​​​​​​​

    • @nageshnimmala7366
      @nageshnimmala7366 Місяць тому

      @nikoo28 thank you for clarification

  • @Wala-fd2kt
    @Wala-fd2kt Місяць тому

    i hope if ure a muslim