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:
- 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)
- 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?
- 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.