How to achieve immediate consistency in microservice architecture?

Deadly 提交于 2019-12-06 10:55:10

问题


For example amazon.com; they rely on microservice architecture and probably order and payment are seperate micro services but when you checkout order on amazon.com you can finally see the order id and details.If it's not eventual consistency approach what is it? Maybe 2PC?

I'm generalizing my question; what if eventual consistency is not appropriate for business transaction(end user should see the result end of transaction) but seperate microservices is meaningful(like order and payment) how to handle immediate consistency?


回答1:


There are several techniques which can provide cross-service transactions (atomicity): 2PC, Percolator's transactions and Sagas.

Percolator's transactions have serializable isolation level. They are known in the industry, see: Amazon's DynamoDB transaction library, CockroachDB database, and the Google's Pecolator system itself. A step-by-step visualization of the Percolator's transactions may help you to understand how they work.

The saga pattern was described in the late 80s in the Sagas paper but became more relevant with the rise of microservices. Please see the Applying the Saga Pattern talk for inspiration.

But since you mentioned eventual consistency it's important to notice that all of the techniques require individual services to be linearizable (strong consistency) and to support compare and set.



来源:https://stackoverflow.com/questions/46696171/how-to-achieve-immediate-consistency-in-microservice-architecture

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!