Is it possible to implement Multi-Version Concurrency Control (MVCC) on top of MongoDB?

前端 未结 5 444
广开言路
广开言路 2020-12-31 20:09

MongoDB is to me a great database. However there are cases where I really need atomic multi-document transactions. For example to transfer things (like money or reputation)

相关标签:
5条回答
  • 2020-12-31 20:50

    Well when you need real TRANSACTIONS you use RDBMS which are designed to support them :) NoSQLs are faster and more scalable mainly because they don't support transactions.

    If you need both maybe it's a good idea to have transactional layer to support transactions and NoSQL layer for other purposes? In some cases it shouldn't be difficult to create a hybrid system using for example MongoDB and PostgreSQL

    0 讨论(0)
  • 2020-12-31 21:03

    The simplest way is to use locks (two-phase commit), although this is not very efficient in some cases. For higher concurrency some kind of MVCC can be implemented on the top of Mongo. This article provides a good description:

    http://highlyscalable.wordpress.com/2012/01/07/mvcc-transactions-key-value/

    0 讨论(0)
  • 2020-12-31 21:03

    Money transaction can be implemented via two-phase commit : http://www.mongodb.org/display/DOCS/two-phase+commit

    0 讨论(0)
  • 2020-12-31 21:03

    There is an implementation of MVCC on MongoDB available now on GitHub:

    https://github.com/igd-geo/mongomvcc

    0 讨论(0)
  • 2020-12-31 21:10

    MongoDB isn't really designed to work with transactions. There is a really good discussion of how you might be able to implement this over at: http://kylebanker.com/blog/2010/04/30/mongodb-and-ecommerce/

    0 讨论(0)
提交回复
热议问题