Transaction Management in Microservices

Monolithic vs Microservices

Pragmatic approaches for SRP

  • Maintain a set of tables for specific to service in a database When you maintain all the tables in a single database, keep prefix or suffix to each table to indicate the Microservice it belongs to. Do not maintain any foreign key constraints across tables belonging to different Microservices. When the right time occurs move tables specific database server belongs the specific Microservice.
  • Create and use separate database schema for each service Here keep the schema name close to the corresponding Microservice.

Ways to handle transactions in Microservices

  • Avoiding transactions across Microservices
  • Two-Phase Commit Protocol
  • XA Standard
  • REST-AT Standard Draft
  • Eventual Consistency and Compensation

Avoiding transactions across Microservices

Two-Phase Commit Protocol

  1. Prepare phase
  2. Commit or Rollback phase

Prepare Phase:

Commit or Rollback phase:

  • XA Standard
  • REST-AT Standard Draft

Eventual Consistency and Compensation

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
WalkingTree Technologies

WalkingTree Technologies

385 Followers

WalkingTree is an IT software and service provider recognized for its passion for technology.