首页 > 其他分享 >Microservice - Data Consistency

Microservice - Data Consistency

时间:2023-11-13 18:56:50浏览次数:105  
标签:transaction based service saga Data next Consistency Microservice local

To have data consistency in a distributed system, you have two options: a two-phase commit (2PC) and saga.

 

2PC coordinates all the processes that form distributed atomic transactions and determines whether they should be committed or aborted.

 

 

A saga is a sequence of local transactions that updates each service and publishes another message to trigger another local transaction on the next service. Because transaction steps are spanned across the services, they cannot be handled with an annotation or two lines of code. However, there are widely used practices with saga, so you don’t need to reinvent the wheel for your use cases. Choreography- and orchestrator-based sagas are the most popular patterns for interservice communication to have consistent data.

 

A choreography-based saga is a pattern in which each service executes its local transaction and publishes an event to trigger the next service to execute its local transaction.
Whenever a saga is created, it can be completed in the following patterns:
 Service returns the result to the client once the saga is completed. It receives an event to update its domain object’s status as succeeded or failed.
 A saga is created, and the client starts to poll the next service to get either a succeeded or failed response. The unique identifier to start polling should be directly returned when the saga is created.
 A saga is created, and the client uses a WebSocket connection in which the service sends the result back using WebSocket protocol. A saga will be completed once the succeeded or failed result is returned.

Service communications over queue can be handled in two ways:
 Command channels—The publisher sends a message directly to the next service with a replyToChannel parameter so that it can notify the consumer once it completes the operation and commits the transaction. The main drawback of this pattern is that the publisher needs to know the location of the next service.

 Pub/sub mechanism—The publisher publishes a domain event, and interested consumers can consume messages to process and commit a local transaction. The main disadvantage of this notation is that it is a possible single point of failure since all the subscribers use one broker technology and all the events are sent to consumers.

 

An orchestration-based saga consists of an orchestrator and participants, and the orchestrator tells participants what to do. The orchestrator can communicate with participants using a command channel or request/response style. It connects participants individually to tell them to execute their local transactions and decides the next step based on this response.

 

标签:transaction,based,service,saga,Data,next,Consistency,Microservice,local
From: https://www.cnblogs.com/zhangzhihui/p/17829862.html

相关文章

  • Databend 开源周报第 119 期
    Databend是一款现代云数仓。专为弹性和高效设计,为您的大规模分析需求保驾护航。自由且开源。即刻体验云服务:https://app.databend.cn。What'sOnInDatabend探索Databend本周新进展,遇到更贴近你心意的Databend。用户案例:DatabendCloud在AIGC初创公司中的应用Dat......
  • 关于Dataframe数据保存出现的问题
    问题描述:读入csv文件,执行以下程序importpandasaspdimportnumpyasnp#pd.set_option('max_colwidth',2000)sub_file_name="submission.csv"df=pd.read_csv(sub_file_name,header=None)pro_file_name="problem.csv"df2=pd.read_csv(pro_fi......
  • excel导出datatable数据
    使用NPPlus处理excelprivatevoidSaveToExcel(stringexcelPath,DataTabledataTable){//excelPath为excel文件路径,如果没有,需要使用FileStream来创建,而不是使用FileInfoExcelPackage.LicenseContext=OfficeOpenXml.Licens......
  • 性能、安全和稳定,袋鼠云数据服务DataAPI为企业 API 保驾护航
    通过API对外提供数据服务是大部分企业中比较常见的数据应用方式,对于API平台管理者、开发者和调用者来说,API的调用性能、安全性和稳定性是在平台选型时最需要考虑的三个因素。袋鼠云API开发及管理平台【数栈-数据服务DataAPI】通过多种手段标准化管控服务,可完成从API创建、......
  • 问题解答:SAP OData V2 和 V4 里针对日期类型的字段进行过滤操作(filter)的正确语法试
    我的知识星球里有朋友咨询一个问题:我测试了一个S/4HANAcloud的purchaseorder的API,这个是ODATAV4格式的。在对CreationDate做filter后运行有报错Invalidparametertypeusedwithfunction'eq'.对datetime字段做filter,一直搞不清楚格式。请帮忙看一下。本文就安排这......
  • 火山引擎 DataLeap 计算治理自动化解决方案实践和思考
    更多技术交流、求职机会,欢迎关注字节跳动数据平台微信公众号,回复【1】进入官方交流群【导读】本文旨在探讨火山引擎DataLeap在处理计算治理过程中所面临的问题及其解决方案,并展示这些解决方案带来的实际收益。主要内容包括:探讨面临的痛点和挑战提供自动化的解决方案分析实践效果......
  • 火山引擎 DataLeap 计算治理自动化解决方案实践和思考
    更多技术交流、求职机会,欢迎关注字节跳动数据平台微信公众号,回复【1】进入官方交流群 【导读】本文旨在探讨火山引擎DataLeap在处理计算治理过程中所面临的问题及其解决方案,并展示这些解决方案带来的实际收益。主要内容包括:探讨面临的痛点和挑战提供自动化的解决方案......
  • A Latent Hidden Markov Model for Process Data读文献笔记
    【个人笔记】:笔记(ALatentHiddenMarkovModelforProcessData)\SummaryResponseprocessdatafromcomputer-basedproblem-solvingitemsdescriberespondents'problem-solvingprocessesassequencesofactions.Suchdataprovideavaluablesourcefor......
  • Oracle database 清理日志文件
    Oracledatabase清理日志文件(listener.log/alertlog)监听日志清理(listener.log)以oracle用户登录,切换到以下目录[oracle@oracledb/]$cd$ORACLE_BASE/diag/tnslsnr/服务器用户名/listener/trace/停止监听服务进程(tnslsnr)记录日志[oracle@oracledbtrace]$lsnrctlsetlo......
  • LACP(Link Aggregation Control Protocol Data Unit,LACPDU)
    1、手工模式配置流程:1)创建ETH-trunk1interfaceEth-trunk12)将端口配置为Eth-Trunk1intg0/0/1Eth-trunk13)配置Eth-trunk类型interfaceEth-Trunk1portlink-typetrunkporttrunkallow-passvlan2to40944、主动端与被动端(越小越优先)系统视图模型下:lacppriority0-655......