Saga pattern in Kafka based micro-services – let’s do distributed commits

Often times there is a need to create the concept of an atomic commit in a distributed system. Consider the following scenario: you split your former monolith into several micro-services, that communicate among them via asynchronous message passing. If a business process requires the contribution of several services, it might be the case that a single service failure implies the rollback of the entire flow. A practical example is the processing of a web store’s shopping basket, if the credit card service is unable to charge the customer, the order must be canceled.

This article presents the saga pattern and discusses its implementation in a Kafka based micro-services system.

Moving away from 2PC

The saga pattern

Creating a saga

Injecting a saga into a Kafka message

Deduplication

Sagas benefits

Conclusions

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s