14

I am planning to use a NoSQL database like MongoDB as the back-end for my web product. For design concept, there would be around daily minimum 1,000 users. I have doubts:

  1. I have read in a blog that NoSQL database are not so good for Online Money Transaction i.e. where data integrity is highest importance: atomicity, consistency, isolation, and durability.

  2. Will also availability be a problem?

Are there more pros and cons related to NoSQL database? Can MongoDB satisfy data integrity and availability?

Cloud Cho
  • 1,594
  • 19
  • 22
Akamad007
  • 1,551
  • 3
  • 22
  • 38
  • 2
    It's highly recommended to have transactions in such systems. You can emulate transactions with nosql but you will invent the wheel. – varela Sep 13 '11 at 09:25
  • @varela:Can you please elaborate your point, I am unable to understand what exactly you have to say. – Akamad007 Sep 13 '11 at 09:30
  • 1
    the most problem is concurrency. If you want for example substruct money, than you cannot just 1) check available amount 2) substruct if user have money. You need to lock user account from changes first with special flag and then do operations. With SQL databases you have standard ways to do this. – varela Sep 13 '11 at 09:37
  • It depends on what you want to do. MongoDB supports atomic operations, but if your update cannot be done in one operation it can be a problem. It's not related with money operations, it's rather the concept of mongoDB. http://www.mongodb.org/display/DOCS/Developer+FAQ#DeveloperFAQ-HowdoIdotransactions%2Flocking%3F – varela Sep 13 '11 at 09:52
  • 3
    @Akash, what is the reason you want to use a NoSQL database for your backend? Just to learn it? Because it is cool? Or there is an actual benefit? But even if you go for it, take a look at something more reliable than MongoDB ( e.g. Riak ). /litius – tolitius Sep 22 '11 at 20:37
  • @litius,the reasons are 1)We are planning to expand. And dont want the database to be a constraint. 2)From what i have read, in no sqldatabase we dont have to think about the schema a lot. 3)The maintenance required for nosql database is very less. 4)We have consulted a few startups who are already using it, they have not had any major issues off recently.(I wanted a more global opnion on this issue,so the question here) 5) And yes it is very cool :D ... Thanks for your suggestion I will certainly look at Riak :) – Akamad007 Sep 23 '11 at 10:54

2 Answers2

34

NoSQL databases are there to solve several things, mainly:

  • (buzz) BigData => think TB, PB, etc..

  • Working with Distributed Systems / datasets => say you have 42 products, so 13 of them will live in Chicago datacenter, 21 in NY's and another and 8 somewhere in Japan, but once you query against all 42 products, you would not need to know where they are located: NoSQL DB will. This also allows to engage a lot more brain power ( servers ) to solve hard computational problems [ does not seem it would fit your use case, but it is an interesting thing to note ]

  • Partitioning => having your DB be easily distributed, besides those cool 8 products in Japan, also allows for an easy data replication, so those 42 products will be replicated with a factor of 3, for example, which would mean you DB would have 3 copies for every product. Hence if something goes down, no problem => here is a replica available. This is where NoSQL databases actually shine vs. RDBMS. Granted you can shard, partition and cluster Oracle / MySQL / PostgreSQL / etc.. BUT it is a several magnitudes more complicated process and usually a maintenance headache for most people you'd employ.

(to your questions)

  • There will be around daily minimum 1000 users

    1000 users daily is an extremely low volume, unless you choose a NoSQL solution that was written yesterday at 3 a.m. as a proof concept, there should be no worries here. But if you are successful, and will have 100,000,000 users in a couple of months, NoSQL would be simpler to scale.

  • Will availability be a problem ?

    Solid NoSQL solutions allow you to specify something that is called a quorum: "The quantity of replicas that must respond to a read or write request before it is considered successful". Some solutions also do something called a hinted handoff: "neighboring nodes temporarily take over storage operations for the failed node". In general, you should be able to control availability depending on your requirements.

(from your comments)

  • We are planning to expand. And dont want the database to be a constraint

Expanding is a very relative term. "Financial industry is pretty expanded", and they still mostly use RDBMS for day to day operations. Facebook uses MySQL. Major banks, I did work for, use Oracle / MySQL / PostgreSQL / DB2 / etc.. and only some of them do use NoSQL, but NOT for data that requires 100% consistency all the time. Even Facebook uses Cassandra only for things like "inbox search". But if by expand you mean more data and more users ( requests, connections, etc.. ), NoSQL will be a lot easier to scale. Again, it does not mean that you can't scale RDBMS, it is just more tedious/complicated.

  • From what I have read, in no SQL database we dont have to think about the schema a lot

In my experience, if I build a system that is any good, I ALWAYS have to think about the schema. NoSQL databases allow you to be a bit more flexible with the data you persist, but it does not mean you should think about the schema any less. Think of indexing the data for example, or sharding it over multiple clusters, or even contracts/interfaces that you may expose to clients, etc..

  • The maintenance required for NoSQL database is very less

I would not say this is true in general, unless we are talking about BigData. Take PostgreSQL for example. It is an extremely awesome piece of software, that is quite easy to work with and maintain. Another plus to RDBMS world => people feel A LOT more comfortable with SQL. For that reason, for example, Cassandra guys, released CQL in 0.8, which is a very limited subset of SQL. Terms like maintenance also should stand shoulder to shoulder with terms like Talent, Knowledge, Expertise. Since if you use Cassandra, for instance, that girl is a very "high maintenance", but not for guys from DataStax who do have Expertise, but you'd have to pay for that.

Your Main Question

  • I have read in a blog that NoSQL database are not so good for Online Money Transaction i.e. where data integrity is highest importance.( My product has Online money transactions )

Without truly knowing what your product is, it is hard to say whether a NoSQL database would / would not be a good fit. If the primary goal of the product is "Online Money Transaction", then I would suggest against NoSQL database ( at least today in the year of 2011 ). If "Online Money Transaction" is just one of the requirements, but not "the core" of your product, depending on what "the core" is, you can definitely give NoSQL database a try, and for example use an external service to process (e.g. Google Checkout, etc..) your transactions with a guaranteed consistency.

As a technical note, if the problem you are trying to solve benefits from being solved with distribution, I would recommend databases that are written in Erlang ( e.g. Riak, CouchDB, etc. ), since Erlang as a language already solves successfully most of distributed things for decades.

tolitius
  • 22,149
  • 6
  • 70
  • 81
  • thanks a lot ... this is amazing stuff.This is too good. If i could give 100 upgrades to it i would... – Akamad007 Sep 23 '11 at 16:25
  • @Akash, sure, very welcome. Wish you build a great, solid system with the SQL or without :) /Anatoly – tolitius Sep 23 '11 at 16:34
  • Facebook doesn't use MySQL. It uses a NoSQL solution. – Marc-François Mar 08 '12 at 08:02
  • of course Facebook [uses MySQL](https://www.facebook.com/notes/facebook-engineering/mysql-and-database-engineering-mark-callaghan/10150599729938920). And MySQL [thinks so](http://mysql.com/customers/view/?id=757) too. It also used to use Cassandra for the Inbox Search, which is now [replaced with HBase](http://www.infoq.com/presentations/HBase-at-Facebook) – tolitius Mar 08 '12 at 14:41
  • Regarding "requires 100% consistency all the time", would you share how multiple tables/databases located in different servers could achieve this with SQL database like mysql? JOIN every second? – Cloud Cho Aug 10 '23 at 23:46
1

MarkLogic is a NoSQL database with ACID transactions that gets used to manage both virtual currency in games as well as real-life banking trades.

Eric Bloch
  • 2,882
  • 2
  • 20
  • 26