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
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.
Amazing video thank you !!
thanks
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
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.
@nikoo28 thank you for clarification
i hope if ure a muslim