I’m reading about eventual consistency in couchDB. I’m somewhat confused by the term and its consequences on an application.
Let’s say I’m building a distributed e-commerce website where monetary transactions are critical. There could be online auctions running and people bidding on them in real time.
Will using a eventual consistent DB such as couchDB be a wrong solution? Should I favor a more consistent solution such as a relational database?
Is couchDB suitable for something non critical such as a social network where one wouldn’t mind if his news feed isn’t up to date or when comments on his posts are somewhat delayed by few seconds?
Update
I’m talking about building a distributed system. I think in case of a single server nothing of this will matter.
6
The eventual consistency part has to do with distributed systems– that is, when there is more than one copy of the data and it needs to be consistent. It’s basically the difference between synchronous and asynchronous replication.
So, it’s not an issue if you have a single server. It’s also not an issue if your system (Couch) has a synchronous mode of operation.
There’s also no guarantee that conventional databases wouldn’t succumb to this problem (think MySQL replication where slaves are lagging behind the master).
So the answer to your question is: it depends.
1
Think of it this way:
You can use eventual constancy to record and capture each users bids. The fact that the database will take a few mSec to share the bids around is not material.
You can also have a stand alone process that decides which auctions have finished, and which bid won each auction. This process needs to allow a few seconds for eventual consistency to complete so that it is highly likely to have a complete view of all bids. However its decision needs to be final.
The users then can see who has been awarded the auction as per normal. The fact that some users may see this a few mSec earlier than the others again is not material, the key is that if they keep refreshing their page (or receive push messages) they will see it when the replication has made it to their database server.