Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have permission to ask a question, You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please type your username.

Please type your E-Mail.

Please choose an appropriate title for the post.

Please choose the appropriate section so your post can be easily searched.

Please choose suitable Keywords Ex: post, video.

Browse

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Navigation

  • Home
  • About Us
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Contact Us
Home/ Questions/Q 1203

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Latest Questions

Author
  • 62k
Author
Asked: November 25, 20242024-11-25T05:58:07+00:00 2024-11-25T05:58:07+00:00

Saga Microservice Pattern.

  • 62k

Art of Managing microservice using different strategies.

Nowadays developers are moving towards microservice-based architecture, instead of following Monolithic-based architecture.

We have various benefits of using a microservice-based architecture as in microservice every service is responsible for the type of work they plan.

Monolith Vs Microservice.

Once we have successfully developed the code for each of our microservice, they need to communicate amongst themselves.

Also with microservice since we have a different service for handling the transaction, it becomes difficult at times if in case any service responds unexpectedly.

Example

A user has come to your website to purchase a book. The user does everything right, but unfortunately your service fail and user is shown “something needs to be fixed”.
We need to have some mechanism to mitigate that. There should be some way or another which should help user with end to end experience.

Order Cancelled

Saga Pattern: Saga pattern is where each action is a local transaction. Once that transaction is updated it triggers a database update. Once the database update is successful it initiates the next local transaction. Each local transaction has performed some action.

Now what if any local transaction fails, the saga pattern is responsible for undoing every transaction by triggering a series of compensation transactions which does the hard work. It helps undo the entire transaction, returning it to the last stable state.

Saga Microservices has two ways by which they coordinate amongst themselves.

  1. Microservice orchestration.

  2. Microservice choreography.

You can read more about microservices orchestration and microservices choreography in this article. Microservices Orchestration vs Choreography | (Technology)

Why Microservices are required?

About Microservice we have already tried to understand. Having individual services is based upon the requirement. We have the opportunity to easily scale in and scale out the service.

Microservices

The individual services are standalone and tend to perform as single set related actions. For example, if we have an order microservice. We can assume this service will be performing all the actions related to order management.

We don't need to worry about the other services, as the service owner can work on scaling the service at the individual level. We can choose our technology stack for that service based on the requirement of the service

Benefits of Saga Architecture Patterns

If one uses saga architecture patterns while designing the architecture, it ensures that either all the transactions will be either fulfilled successfully. If the transaction is unable to commit successfully, a compensatory transaction will be triggered to undo the work.

We have both ways of implementing the Saga pattern, either using microservice orchestration or microservice choreography. At the end of your entire design of the architecture, the final goal will always be to either commit to a transaction in its entirety.

In any case, if a transaction is stored in an incorrect state, i.e. partial information is maintained, and the compensation transaction is not triggered properly that would be an incorrect implementation of the entire process.

Points to Be Notes In Saga Design Pattern.

Transaction

Transaction as the name suggests is any action performed in the Saga design pattern. Its goal is to perform any action completely and launch a compensation transaction in case anything fails

Compensable Transaction

A compensable Transaction can be considered as any transaction which is triggered to bring the state into the back stable stage. The compensable transaction is triggered when any issue occurs in normal transactions.

Retrybale Transaction

Retryable transactions are that transaction which is triggered post-pivot transactions are guaranteed to succeed. The pivot transaction is those which if committed, are neither Retryable nor compensable.

When to User Saga Pattern?

We can use the saga pattern if our application support one of the following case. If our application is loosely coupled and the different transactions can be performed individually.

Secondly, if in any particular case, we need to require to roll back the series of transactions in the case of the distributed system. The saga pattern helps you roll back the state to the last stable stage in case of system errors.

Final Thoughts.

Now to wrap up, we understood about saga pattern. The goal of adopting the Saga pattern is to achieve a state in your application which is either completely fulfilled or reverted accordingly.

If you have implemented the Saga pattern properly, chances are rare that your application is committed in a partial state.

architecturedevopswebdev
  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question

Stats

  • Questions 4k
  • Answers 0
  • Best Answers 0
  • Users 2k
  • Popular
  • Answers
  • Author

    ES6 - A beginners guide - Template Literals

    • 0 Answers
  • Author

    Understanding Higher Order Functions in JavaScript.

    • 0 Answers
  • Author

    Build a custom video chat app with Daily and Vue.js

    • 0 Answers

Top Members

Samantha Carter

Samantha Carter

  • 0 Questions
  • 20 Points
Begginer
Ella Lewis

Ella Lewis

  • 0 Questions
  • 20 Points
Begginer
Isaac Anderson

Isaac Anderson

  • 0 Questions
  • 20 Points
Begginer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Footer

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore, ask, and connect. Join our vibrant Q&A community today!

About Us

  • About Us
  • Contact Us
  • All Users

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Help

  • Knowledge Base
  • Support

Follow

© 2022 Querify Question. All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.