Joseph Cheung (9) [Avatar] Offline

It's a great course and I really enjoy watching it.

I got a question about serverless lambda orchestration. As you may know, there are multiple ways to orchestrate functions to invoke one another:

1. Call lambda directly by using aws sdk
2. Trigger lambda by sending SQS/SNS message, example:
3. Use dynamodb event to trigger lambda, example:
4. Create a new Serverless service and expose API endpoints for other service to call
5. Use AWS step functions to create a finite state machine

I believe there are more ways to orchestrate lambda invocations, but which method should we pick under what scenario? What do you think?

Yan Cui (71) [Avatar] Offline
Hi Joseph,

Thank you, glad you're enjoying the course smilie

This is a very complex question to answer because there are so many considerations to make and there is no one right answer and I'm hesitant to give general advice on when to use what. Perhaps if you have a use case in mind then that can narrow the conversation down to something manageable.

Here are just a few of the trade-offs to consider:

  • cost at different levels of scale

  • concurrency

  • retry behaviour

  • partial failure handling

  • reporting and tracing

  • I will address various aspects of these throughout the course, but in the meantime you might find this post of interest - in there I discussed several of these factors in relation to different choice of event sources (e.g. SNS vs Kinesis vs DynamoDB vs SQS, vs calling functions directly).
    Joseph Cheung (9) [Avatar] Offline
    Hi Yan,

    I agree that it's a complex topic and I believe we'll utilise multiple of them when building a loosely-coupled serverless app.

    At the moment I created a prototype of our graphql backend using just 1 lambda. I'm investigating different microservice architecture patterns I can use to split the monolithic application into smaller services using Serverless.

    I personally hope that there will be another course talking about different patterns we can implement using AWS / Serverless framework, like the saga / pub-sub / push-pull / fan-in fan-out patterns you mentioned in your blog posts, and also considering the trade-offs we need to make when applying these patterns smilie

    Yan Cui (71) [Avatar] Offline
    Hi Joseph,

    Funny you should mention that, after we wrap up this course we are considering doing other courses that are focused on design patterns and/or security, it's good to hear your feedback and interest in such a course.

    As for a GraphQL backend with Lambda, I remember seeing a couple of template projects being mentioned on social media a while back, try googling for them and see if they can offer you some inspiration. From my point of view, I'd probably approach it with API Gateway + Lambda to parse the GraphQL query, then based on configuration, make concurrent requests to APIs (API Gateway + Lambda) that govern the requested resources.

    Amazon also announced AppSync at re:invent, have you tried requesting for access to the preview? It would replace the need for you to write your own GraphQL function and it'll handle parsing the query for you. All you need to do is to set up the mapping from resource to target (API/Lambda, etc.).

    Hope this helps.
    Joseph Cheung (9) [Avatar] Offline
    Hi Yan,

    Yeah, it definitely helps! Look forward to the possible new course! smilie

    What I'm using in the prototype is I'm thinking of splitting multiple resources into internal services and expose their own GraphQL API for the public facing GraphQL service to stitch them together smilie

    Haven't heard of AppSync before, will definitely look into it!

    knelyo (1) [Avatar] Offline
    I am also learning a great deal of new materials from this course. I purchased the training because i need to learn and code lambda orchestration for efficiency...

    Relating to this topic i have a use case that requires writing a lambda function that only "fetch and return an IdToken" from a cognito User Pool. assuming the user already signed up to the cognito user pool.

    which is more prefered? should i just expose the lambda as an API endpoint or should i expose it via API Gateway.

    regarding your preferred method to expose the API could you please provide the code stub that will suffice for the solution. section 2 of the course did touch on this use case by am not sure how to return just the IdToken

    I am honestly new to Node.Js Programming.

    Thank you in advance.