本文介绍了如何在微服务架构中实现即时一致性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如amazon.com;他们依赖微服务架构,可能订单和付款是单独的微服务,但是当您在amazon.com上结帐订单时,您最终可以看到订单ID和详细信息.如果不是最终的一致性方法,那是什么?也许2PC?

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?

推荐答案

有几种技术可以提供跨服务交易(原子性):2PC,Percolator的交易和Sagas.

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

过滤器的交易具有可序列化的隔离级别.它们在业内已广为人知,请参阅:亚马逊的 DynamoDB事务库 CockroachDB数据库以及Google的Pecolator系统本身.过滤器交易的分步可视化帮助您了解它们的工作原理.

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.

在80年代末, Sagas 论文,但随着微服务的兴起而变得越来越重要.请参阅应用传奇模式以获得灵感.

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.

这篇关于如何在微服务架构中实现即时一致性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 08:08