Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

荐:微服务中怎么处理分布式事务? #23

Open
vonzhou opened this issue May 25, 2020 · 0 comments
Open

荐:微服务中怎么处理分布式事务? #23

vonzhou opened this issue May 25, 2020 · 0 comments

Comments

@vonzhou
Copy link
Owner

vonzhou commented May 25, 2020

难度系数:☆☆☆

如果应用由单体架构演变成了微服务架构,都会涉及到分布式事务的问题。

  1. 2PC 两阶段提交

引入了事务管理器来管理多个参与者的事务生命周期:

优点:

  • 能保证事务的原子性
  • 读写隔离
  • 同步调用

缺点:

  • 比较重,依赖事务管理器
  • 可能会出现死锁
  1. 最终一致性和事务补偿

基于事件驱动的方式,每个服务基于事件/消息更新本地的数据/状态,然后发布新的事件。

优点:

  • 解耦
  • 每个服务关注自身的事务原子性
  • 异步调用,支持高可扩展

缺点:

  • 无读写隔离,会读到脏数据
  • 服务多的话难以维护

原文

image

@vonzhou vonzhou changed the title 阅读推荐:微服务中怎么处理分布式事务? 荐:微服务中怎么处理分布式事务? May 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant