douzhankui0758 2019-03-10 11:05
浏览 59
已采纳

组织调用lambda函数

I've got the order microservice that's written as go AWS lambda function.

The main function named order-service bound to API Gateway. It receives several parameters like user_id:int, product_ids:array of int, creates an order with artifacts and returns serialized order with order_id and total price. This function invokes a function named order-item which creates an order-item and returns them in parallel(per product). These functions invoke product and user functions to retrieve information about user and products by their ids. Then, the order function invokes another lambda called fee-function which takes just total price and user id and gives back fee price. Of course, it calls some other function like user function and so on. Basically, this is a simple example of how the service works in general. Any function calls some others like user-discount, state taxes etc.

The questions are:

  1. Is it good that order function invokes fee function through Amazon, but it can just import fee handler package and run it inside itself?(However, fee function may be called from outside so it must be deployed as a separate function as well)
  2. Is it good that each function receives just user id and loads the user invoking user function? Perhaps, better to preload it and pass it through everywhere? Something else?
  3. Is it good that one function calls other functions and they call some others and so on? is there any better approach in my situation? Use SNS, Step function, dependency injections/aws layers.

The main reason why I asked is to withstand thousands of RPM and not pay a lot.

Thanks for helping. I appreciate this.

  • 写回答

1条回答 默认 最新

  • dtotuki47568 2019-03-10 13:15
    关注

    This is exactly what Step Functions was created for. You can invoke a Step Functions state machine from API Gateway, as you would a Lambda.

    With Step functions you can:

    • Invoke the state machine with parameters
    • Orchestrate the order that Lambda functions are invoked
    • Use the state to store inputs and outputs from each lambda
    • Have decision points to take different paths based on the output of a previous function

    See the AWS Step Functions Getting Started Guide for a good introduction to the service.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥30 最小化遗憾贪心算法上界
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝