Eventual consistency:
- I watch the weather report and learn that it's going to rain tomorrow.
- I tell you that it's going to rain tomorrow.
- Your neighbor tells his wife that it's going to be sunny tomorrow.
- You tell your neighbor that it is going to rain tomorrow.
Eventually, all of the servers (you, me, your neighbor) know the truth (that it's going to rain tomorrow), but in the meantime the client (his wife) came away thinking it is going to be sunny, even though she asked after one or more of the servers (you and me) had a more up-to-date value.
As opposed to Strict Consistency / ACID compliance:
- Your bank balance is $50.
- You deposit $100.
- Your bank balance, queried from any ATM anywhere, is $150.
- Your daughter withdraws $40 with your ATM card.
- Your bank balance, queried from any ATM anywhere, is $110.
At no time can your balance reflect anything other than the actual sum of all of the transactions made on your account to that exact moment.
The reason why so many NoSQL systems have eventual consistency is that virtually all of them are designed to be distributed, and with fully distributed systems there is super-linear overhead to maintaining strict consistency (meaning you can only scale so far before things start to slow down, and when they do you need to throw exponentially more hardware at the problem to keep scaling).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…