SAGA | Microservices Architecture Patterns | Tech Primers

Поділитися
Вставка
  • Опубліковано 16 січ 2025

КОМЕНТАРІ • 204

  • @tirupatirao7521
    @tirupatirao7521 3 роки тому +142

    Got selected in an interview only by explaining to this one question bcz of this 👌

    • @TechPrimers
      @TechPrimers  3 роки тому +1

      Glad it was helpful 😄

    • @kurtcampher4716
      @kurtcampher4716 3 роки тому

      That's awesome

    • @curiossoul
      @curiossoul 3 роки тому +31

      Really? Interviewer didnt ask you where is the distributed transaction scenarios here. What he explained is actually food delivery service and partially SAGA pattern.
      What happens if payment fails or resturant svc fails etc... SAGA implements the concept of comkit or rollback which he totally skipped in the video

    • @santoshtavargeri
      @santoshtavargeri 3 роки тому +1

      You owe first salary to channel!

    • @44047aayush
      @44047aayush 2 роки тому +1

      @@curiossoul So true. Agreed.

  • @Pjblabla2
    @Pjblabla2 2 роки тому +2

    Very nicely explained

  • @manukumarkm9304
    @manukumarkm9304 3 роки тому +1

    Simple & Elegant

  • @sanjayshukla5255
    @sanjayshukla5255 3 роки тому +1

    Very good explanation.

  • @saurabh_panjiara
    @saurabh_panjiara 2 роки тому +1

    Great content ,Thanks for sharing

  • @rahulvutukuri9254
    @rahulvutukuri9254 3 роки тому

    much needed video, since i have been searching how a client request is deserialized and executed by multiple micro services

  • @EaswaranParamasivam
    @EaswaranParamasivam 10 місяців тому +1

    Awesome!! Keep up the good work!!!

  • @mumbaimuru
    @mumbaimuru 3 роки тому +1

    Nice explanation

  • @ngneerin
    @ngneerin 4 роки тому +4

    Thanks Tech Primer for the tutorial. Would appreciate more content around microservices

  • @rajivraghu9857
    @rajivraghu9857 5 років тому +16

    Super.. can you do a video on the coding for the same using SAGA pattern

  • @javisartdesign
    @javisartdesign 5 років тому +6

    well explained! I would talk about distributed transactions and compensation operations for the rollbacks.

    • @javisartdesign
      @javisartdesign 5 років тому

      @Z3U5 CQRS pattern is not used for distributed transactions SAGA deals with that since it is its common use.

  • @shivraj777
    @shivraj777 5 років тому +3

    Nice and clean explanation. What we see across multiple forums is explanation on Saga. But not coding example. Would be nice to see coding example for the same example.
    The two components to see in coding example will be
    1. how microservices handle multithreading (specially for crud operations assuming every microservice has its own database)
    2. How data consistency is maintained across these 4 microservices (as per example in video). This one has two elements - first one being every microsrvice has its own database and second one being all have shared database.

  • @adrienmbiandji8282
    @adrienmbiandji8282 5 років тому +2

    Tanks you. Will glad see the corresponding code

  • @Javoke
    @Javoke 3 роки тому +1

    Your explanation was flawless! Thanks in advance for sharing your knowledge

  • @CyberPrabhjot
    @CyberPrabhjot 3 роки тому +2

    thanks... this is awesome

  • @mr-black_rock321
    @mr-black_rock321 4 роки тому +6

    orchestrator pattern introduce the high degree of coupling . please let us explain how compensation event would process ?

  • @mohtashimraghib5964
    @mohtashimraghib5964 3 роки тому

    Very Helpful Man. Thanks

  • @jka9524
    @jka9524 5 років тому +1

    Nice explanation and good to learn. Nice Bro

  • @sriaya1743
    @sriaya1743 4 роки тому +1

    Nice video sir.

  • @karan6551
    @karan6551 4 роки тому +1

    Awesome ❤️🔥❤️🔥❤️🔥❤️🔥❤️❤️

  • @murlidew
    @murlidew 4 роки тому

    Very well explained. Thanks for the video.

  • @rahulrajsaini5670
    @rahulrajsaini5670 4 роки тому +1

    Nice one.. Thanks for this...!!!

  • @youee1234
    @youee1234 5 років тому +2

    thank you very much
    it was really simple and clear

  • @danielgospodinow
    @danielgospodinow 4 роки тому +2

    Wonderful explanation! Thank you!

  • @HenryPolen4890
    @HenryPolen4890 5 років тому +1

    nice video and it's pleasant to listen to you despite some accent

  • @anupkmr03
    @anupkmr03 5 років тому +2

    Awesome....very clear explanation. Thank you so much :)

  • @br4676
    @br4676 5 років тому +1

    thanks sir for very nice information

  • @VijendraSingh-ye5nl
    @VijendraSingh-ye5nl 4 роки тому +1

    Thanks

  • @MikeNoli1
    @MikeNoli1 3 роки тому +5

    Very clear, it 'd be great to develop an example with lambdas/spring cloud in AWS

  • @farziaccount1792
    @farziaccount1792 5 років тому +1

    Nice explaination

  • @anirbanroy1524
    @anirbanroy1524 5 років тому +1

    Excellent

  • @redusuda8261
    @redusuda8261 3 роки тому +4

    How to handle failures in these patterns, how you will define compensating events

  • @madhavar980
    @madhavar980 4 роки тому +2

    Super bro. Can you prepare one spring boot example with SAGA implementation?

  • @palashchanda4166
    @palashchanda4166 5 років тому +1

    Nice video..well explained.

  • @analogylibrary
    @analogylibrary 5 років тому +1

    What a explanation, kudos!!!

  • @MaheshKumar-gt9td
    @MaheshKumar-gt9td 3 роки тому +3

    It's an awesome tutorial, Can you please make a video with java based code example will be highly appreciated. Thanks

  • @shakhawatstech9616
    @shakhawatstech9616 5 років тому +1

    Very helpful video, Thanks

  • @stepseiventures2528
    @stepseiventures2528 4 роки тому

    You know how to get the job done. Great videos as always.

  • @codewithkashif
    @codewithkashif 2 роки тому +1

    Awesome video, super helpful!
    Which tool have you used it for these diagrams/flow - looks wonderful!!

    • @TechPrimers
      @TechPrimers  2 роки тому

      Google slides

    • @codewithkashif
      @codewithkashif 2 роки тому

      @@TechPrimers thanks for your quick reply! Will explore it! Thanks again😊

  • @danielquirospicado431
    @danielquirospicado431 Рік тому

    Why in the Orchestration option the initial request is not sent to the orchestration service instead of the order service?

  • @919428328929
    @919428328929 4 роки тому +1

    Nicely explained SAGA pattern, Can you explain what is the proper way to handle transaction across the distributed micro services?

  • @growtogether8014
    @growtogether8014 Рік тому +2

    There are two points which needs to be added here: 1. In Choreography pattern how the failures are handled 2. In case of Orchestration pattern the request will not come to order-service the request will come to Orchestration service.

  • @Tommy-dd5pz
    @Tommy-dd5pz 3 роки тому +2

    Great video, clearly explained how each microservices interact with each other, better than a lot of other materials I find on the internet

  • @selenajosephine8931
    @selenajosephine8931 4 роки тому +1

    In case one of the services fail, how does the orchestration service maintain transaction integrity?

    • @JamesSmith-cm7sg
      @JamesSmith-cm7sg 4 роки тому +1

      The same as Choreography approach, expect the orchestrator is calling the service. Every step in the first phase of a saga has a rollback (they call it "compensating") action, so it's on the orchestrator to call services in the pervious steps to initiate a rollback action. For example in his diagram, if payment failed the orchestrator calls the order service notifying of a payment failure and the order service action would be to updates the order status to "payment failed"

  • @1711nitish
    @1711nitish 3 роки тому +1

    Nice explanation. Could you pls provide inputs on how orchestration is different from two phase commits .It looks like they both work the same way .

    • @TechPrimers
      @TechPrimers  3 роки тому

      Orchestration does things more than two phase commit

  • @arzunkumar9
    @arzunkumar9 2 місяці тому

    Do you have code example for this @tech primers

  • @muthahirnawaz2479
    @muthahirnawaz2479 5 років тому +1

    Well explained... Thanks

  • @satyaanvesh7051
    @satyaanvesh7051 3 роки тому +1

    can u upload an example

  • @jasper5016
    @jasper5016 2 роки тому +2

    Fantastic explanation. Thanks so much. Can you please show this at code level? It would been better to see it in action.

  • @murali1790able
    @murali1790able Рік тому

    good explanaion about those patterns but motivation is missing. Also in orchestration pattern, does Orchestrater makes sync api call to each service and gets the response or it sends an event and receives an event as a response?

  • @micaelgeiss9585
    @micaelgeiss9585 5 років тому +1

    Nice video. Ty

  • @gopalakrishnapeddi6686
    @gopalakrishnapeddi6686 5 років тому +2

    Thank you Team. Got clear picture about saga usage. I am implementing it. Yet I have many doubts. When will you release the video on coding part. Please make a video of this implementation.

    • @gopalakrishnapeddi6686
      @gopalakrishnapeddi6686 5 років тому

      Thanks for your acknowledgement. Please make video on Saga implementation with .net c#

  • @sopanhalse
    @sopanhalse 2 роки тому

    After payment service updated the db what if order service failied , how it will rollback the payment service changes ?

  • @thewhitewolf2912
    @thewhitewolf2912 3 роки тому

    is there a good book to learn all consistency concepts in micro services..?

  • @hydtechietalks3607
    @hydtechietalks3607 4 роки тому +4

    Great Video.. In case of Azure, OrchestrationService would be a WebJob or function; The initial event saga pattern is done via Azure Service Bus and Event handlers...

    • @GauravKawatrakir
      @GauravKawatrakir 3 роки тому +1

      Any git repo example

    • @prateekashtikar8631
      @prateekashtikar8631 3 роки тому

      Is there any link to source code please?

    • @morespinach9832
      @morespinach9832 10 місяців тому

      Yeah and that’s a great way to wire yourself to one cloud environment. Silly idea.

  • @Ghungroo-Beats
    @Ghungroo-Beats 2 роки тому

    Which pattern is better? What are the pros and cons?

    • @codewithkashif
      @codewithkashif 2 роки тому

      Hey I have implemented Saga Orchestrator approach as I find it bit better for following reasons:
      * It maintains SAGA logs at one place by default which is very helpful for debugging and tracing purpose
      * Unlike Choreography, Not much documentation required and any new developer can get complete understanding by looking at saga orchestrator, as all the api calls/push are happening from there only.
      * We can also make use of both (http calls and Event Bus) for calling different micro services from coordinator/orchestrator

  • @ZackIOS
    @ZackIOS 5 років тому +2

    Thank youuu

  • @knowledgeseeker3530
    @knowledgeseeker3530 3 роки тому

    Where can I see the code examples implemented based on the explanation in this video?

  • @subhasispanda9000
    @subhasispanda9000 5 років тому +3

    Thanks for the video...
    can you please make one video or give some idea on session interaction between microservices like we have in amazon order MS,payment MS, user MS, cart MS interaction using session how they are interacting by keeping identity of same user?

  • @bajrangigupta5712
    @bajrangigupta5712 4 роки тому

    Please share link of saga implementation

  • @nidhiyadav1570
    @nidhiyadav1570 Рік тому

    what happen when central service goes down?
    In case of event base, what will happen when queue goes down, then how will they interact?

  • @puneetsaneja3007
    @puneetsaneja3007 3 роки тому +1

    Hi. I have few queries on SAGA. Please help me to answer .
    1. Here you cover only happy path , if everything works well. What if payment failed. How they roll back from the order services.
    2. Do it maintain lock at database level. Say in ecommerce application , i have 5 inventory in stock but 10 users are buying at the exactly same time. ? How data consitency are maintained ?

  • @RaffaCaboFrio
    @RaffaCaboFrio 4 роки тому

    Nice video. Thanks

  • @blameItleaveit
    @blameItleaveit 2 роки тому

    What about the transaction rollback or anything bad happened duration the call ?

    • @TechPrimers
      @TechPrimers  2 роки тому

      Check the part 2 for the compensating transaction

  • @sctm81
    @sctm81 5 років тому

    How about the rollback service if the payment fails or if there is a problem with delivery?

  • @sekharatmakuri
    @sekharatmakuri 4 роки тому +9

    good one and very easy to understand. can you also do one for failure handling / rollbacks scenarios?

  • @tarunsoni5131
    @tarunsoni5131 5 років тому +2

    Thanks nice video . I learn lot of things from u r videos . Could you please make video on session management in microservices please ?

  • @iDeveloper92
    @iDeveloper92 Рік тому

    How do you handle failure w/ the saga pattern?

    • @TechPrimers
      @TechPrimers  Рік тому

      There is a Part 2 video on compensating transactions. You can take a look at that

  • @ayasswain
    @ayasswain 4 роки тому +1

    Nice video. I have a question. In the orchestration approach how the message passing happens between the orchestration service and other micro services? Are they REST API calls which make it a synchronous flow? I assume they are not event based where events are pushed to a message queue and consumed from it for processing.

    • @TechPrimers
      @TechPrimers  4 роки тому +1

      Correct. If they are pushed to a queue they become event sourcing/ event based architectures

    • @ayasswain
      @ayasswain 4 роки тому

      @@TechPrimers thanks for replying. My followup question on both the Choreography and Orchestration will be - What happens if the payment fails due to insufficient balance in user's payment method or due to network issue? In my opinion an order should be created only after payment is completed successfully.

    • @TechPrimers
      @TechPrimers  4 роки тому

      Ayaskant Swain yes. In this case the order need to cancelled so addition message/request will be sent to the necessary microservices to update the state to cancelled

    • @sarojsahoo8763
      @sarojsahoo8763 4 роки тому

      @@ayasswain Initially Order State will be in PENDING state after all the microservices has been executed successfully I mean in this example after delivery service completes Order state is going to be changed to Placed/Processed

  • @paraglohiya6951
    @paraglohiya6951 Рік тому +1

    1. There is a mistake Orch Pattern. The Main controller will get first trigger and from there it will call other services as per state change. Order service can't be input.
    Also your diagram for Choreography is incorrect. You never showed Event bus connection.

  • @sarojsahoo8763
    @sarojsahoo8763 4 роки тому

    Hi Ajay , there is a straight forward issue i could see with the above design .Suppose I have ordered 2 items from a Particular resturant and Payment has been completed for 2 items and when request reached to Resturant service it is able to process item1 and deny item2 because of some issue(lets say ingredient is not available) . How I am gonna make the payment reverse in this case.

  • @juchi7516
    @juchi7516 4 роки тому +1

    Use Camuda workflow engine for build sagas. Spring has starter for Camuda.

  • @techtalks561
    @techtalks561 3 роки тому

    I have one query regarding choreography approach.
    If any event published then all linked micro services will be triggered but only micro service will execute logic which matches the event action. is that correct ?

    • @TechPrimers
      @TechPrimers  3 роки тому

      Not necessarily. It's upto us, how it can be implemented. If we use rabbitmq, we can do filtering at the rabbitmq level. If we use kafka, we will have to filter unnecessary messages at app level. We can chose either approach

    • @narayankushwah5
      @narayankushwah5 3 роки тому

      @@TechPrimers Thanks

  • @akshaypatra7676
    @akshaypatra7676 2 роки тому

    Is it possible to have event based orchestration?

  • @123456789sahu
    @123456789sahu 3 роки тому

    If any exception occurs during the transaction say in restuarant service then how Order service will be reverting all the transactions including payments?

    • @TechPrimers
      @TechPrimers  3 роки тому

      Cheek the part 2 of this video, i have explained it there

  • @bimalkumar712
    @bimalkumar712 5 років тому +3

    Getting this type of questions regularly in interview... thanks for explaining.. please give some coding ideas on this...

    • @TechPrimers
      @TechPrimers  5 років тому +1

      sure bimal.

    • @sarojsahoo8763
      @sarojsahoo8763 4 роки тому

      @@TechPrimers Ajay please do a coding session on the same

  • @amitkumar7566
    @amitkumar7566 3 роки тому

    Can you please make a video on this with coding example and live working of it through code.. I am unable to find any coding video on internet

  • @amitkumar7566
    @amitkumar7566 3 роки тому +2

    Could you please help how can we maintain “transaction” where multiple microservices are communicating to each other?
    What if one of them fails during the transaction? How to roll back the persisted data or transaction in other microservices?
    Could you please make a CODING tutorial on Saga (Orchestration/Choreography pattern)? It will be of great help.
    I search a lot for such kind of online tutorials but it’s not available anywhere over internet.

    • @krishnendughosh2368
      @krishnendughosh2368 3 роки тому

      Hi, have you found any coding tutorial on saga? If yes, can you please give me the video or website link?

    • @aniljuneja175
      @aniljuneja175 2 роки тому

      if you have a transaction failed you emit out the event in asynchronous queue and other micro services will get this event and can rollback in its own database.

  • @smritiverma8990
    @smritiverma8990 4 роки тому

    What about the rollbacks transactions?This video is really a very nice introductory video.

  • @bhargavasurimenu7850
    @bhargavasurimenu7850 5 років тому +4

    Great Explanation, Nice thing about your videos is always one step ahead of what Market needs. Really appreciated your skills and service which you are doing ..

  • @ramu7731
    @ramu7731 5 років тому +1

    Nice video!!!! thanks, for the very nice information and can you help to do video Kubernetes scaling master and slave fail how to do autoscaling...

  • @luffyonepiece4526
    @luffyonepiece4526 5 років тому +2

    Pls do the video on saga implementation

  • @anubhavkaushik7944
    @anubhavkaushik7944 3 роки тому

    what if there is multiple order service? then how will multiple service would know which event is meant for it. Or do we need to have multiple topics ?

    • @TechPrimers
      @TechPrimers  3 роки тому

      It would pick in random depending the availability of the threads and the first request which reaches the queue.

    • @anubhavkaushik7944
      @anubhavkaushik7944 3 роки тому

      @@TechPrimers so imagine three different client order service accessing the same payment service, one client should not pick up the event meant for another client, how we do that?

    • @TechPrimers
      @TechPrimers  3 роки тому

      That's the job of the messaging queue. All your services should be part of same consumer group (if you use kafla)

  • @ariantadas7314
    @ariantadas7314 3 роки тому

    Hi Sir one question. How to handle transaction in case of cassandra database. and if we are following database per service pattern.
    Thanks in advance.

  • @simplechannel7859
    @simplechannel7859 5 років тому +4

    Thx! nice video. You are the best! Please show an example. Need real example with code

  • @himanshutomar3512
    @himanshutomar3512 4 роки тому

    A question about orchestrated pattern:
    In this pattern does orchestrator service call payment and delivery service synchronously or via a event?

    • @TechPrimers
      @TechPrimers  4 роки тому

      You can do either. When you do with event it evolves to event sourcing

    • @himanshutomar3512
      @himanshutomar3512 4 роки тому

      @@TechPrimers Bit confused here, Event sourcing is used if I have to create my current state from sequence of events and my events will be persisted in event store say Kafka.
      How that will be used for distributed transaction pattern like orchestrated saga

    • @TechPrimers
      @TechPrimers  4 роки тому

      Your reply all already has the answer.
      Irrespective of which implementation (SAGA) you use, event sourcing is going to help recover your state. So why not SAga

    • @himanshutomar3512
      @himanshutomar3512 4 роки тому

      @@TechPrimers hmmm...make sense Thanks for the help🙏
      One more thing if you could create a video with Orchestrated Saga that would really help us. Thanks in advance 😊

  • @sreddy8141
    @sreddy8141 3 роки тому +1

    It would be really helpful even more if you cover the failure scenarios and roll backs how its gonna handle. Services should build on keeping failure scenarios in mind. Happy flow anyways doesn't challenge the distributed transaction management

    • @TechPrimers
      @TechPrimers  3 роки тому

      There is a Part 2 video with failure handling, take look at that. I uploaded it few days ago

    • @TechPrimers
      @TechPrimers  3 роки тому

      Here is the link for Part 2 ua-cam.com/video/a8RM2xCM9RY/v-deo.html

  • @GauravSharma-wb9se
    @GauravSharma-wb9se 5 років тому

    how will handle the exception in both patterns ?.... specially in event based pattern,

  • @nageshchauhan7101
    @nageshchauhan7101 Рік тому

    What about rollback strategy ??

    • @TechPrimers
      @TechPrimers  Рік тому

      i have made a part 2 video for that Nagesh. We can do compensating transaction for rollbacks

  • @anshulgupta2592
    @anshulgupta2592 3 роки тому +1

    where is the case of failure and rollback?

    • @TechPrimers
      @TechPrimers  3 роки тому

      I have uploaded a new video SAGA 2, i have discussed those as Compensating transaction pattern in SAGAs. Take a look at it

  • @rionti
    @rionti Рік тому

    How the failure is handled, what about compensation

  • @srikanthe6430
    @srikanthe6430 4 роки тому

    Suppose if I want to cancel order then how I do in case of orchestration

  • @sumitbabel5415
    @sumitbabel5415 3 роки тому

    I think it’s wrong , SEC is associated to choreograph and not orchestrate .. I think you explanation is correct for choreography and not orchestrating, because in orchestration each service is responsible for its own compensation, please correct me if I am wrong as other blogs says different

  • @seatconnect224
    @seatconnect224 2 роки тому

    what about compensation transaction?

    • @TechPrimers
      @TechPrimers  2 роки тому

      Ya there is a part 2 video which covers that

  • @sanjuexplore
    @sanjuexplore 4 роки тому

    Simply put. Thanks.
    In Choreography pattern, What would happen if Payment service succeeds but Restaurant service refuses for some reason?
    I assume Payment service will have to listen for the failed event and start Payment reversal process - Compensating Transaction. Any other better way?

  • @sahilGupta217
    @sahilGupta217 5 років тому

    Are these patterns used to maintain concurrency among the microservices??

    • @kousiks2395
      @kousiks2395 5 років тому +1

      its used in microservices devlopment in transactions

    • @sahilGupta217
      @sahilGupta217 5 років тому

      @@kousiks2395 for concurrency between different instances of same microservice?

    • @TechPrimers
      @TechPrimers  5 років тому +1

      nope. different microservice

    • @sahilGupta217
      @sahilGupta217 5 років тому

      Ok, so how to maintain concurrency between different instances of same microservice.

  • @himanshutomar3512
    @himanshutomar3512 4 роки тому +1

    an example of orchestrated saga would be nice. thanks in advance 😊

  • @samarthnarula13
    @samarthnarula13 4 роки тому

    Sir can you create a vedio on Microservice architecture pattern CQRS implemented using spring boot

  • @KrishnaList
    @KrishnaList 5 років тому

    You are saying common queue it means each MS are reading message from queue then in this case order created event could be read any of the services

  • @abeetha87
    @abeetha87 3 роки тому

    Thanks Ajay for the nice tutorial. I got one question. When you use asynchronous communication between microservices through messages, client or the web frontend won't get response immediately. What is the pattern or technology should be used in that scenario? Is using web sockets a good practise in such scenario?

    • @aniljuneja175
      @aniljuneja175 2 роки тому

      No Web socket Connections are not suitable here as you don't need client server communication open every time. once client place an order. client will make long http request or delay calls (like in every 2 second to find out the status) to servers and server can respond back with the current status of the transaction. once client find out the terminal state like transaction success or failure, it will not make http request again. It could be one of the solutions.