Why use Temporal over a combination of AWS Step Functions and AWS Lambda?

SAGA

SAGA pattern is very widely used for microservice orchestration. Step Functions make it really hard to implement it. The main problem is that in any nontrivial workflow, the list of executed activities is very dynamic. So the compensation logic has to know which activities were executed and compensate them accordingly.

Look at this trivial workflow example:

    Saga saga = new Saga(sagaOptions);
    try {
      if (reserveCar) {
        String carReservationID = activities.reserveCar(name);
        saga.addCompensation(activities::cancelCar, carReservationID, name);
      }
      if (bookHotel) {
        String hotelReservationID = activities.bookHotel(name);
        saga.addCompensation(activities::cancelHotel, hotelReservationID, name);
      }
      if (bookFlight) {
        String flightReservationID = activities.bookFlight(name);
        saga.addCompensation(activities::cancelFlight, flightReservationID, name);
      }
    } catch (ActivityFailure e) {
      saga.compensate();
      throw e;
    }

Now think how to represent this using Amazon States Language.

Then extrapolate it to a real application with potentially thousands of possible code paths, and the list of compensation activities to run is different for every path.

11 Likes