Lambda Billing for api code

0

I am trying to figure out api billing, if my api script is running does it incur runtime charges waiting for requests to come in, or runtime charges only apply when requests come in and the script serves them. It is a Python flask api script.

Boris
已提问 6 个月前192 查看次数
2 回答
0
已接受的回答

In Lambda you only pay for the number of invocations and actual duration, i.e., from the time your function receives a request until it returns an answer. If there are no API calls, you pay nothing.

profile pictureAWS
专家
Uri
已回答 6 个月前
profile picture
专家
已审核 1 个月前
profile pictureAWS
专家
已审核 6 个月前
  • That makes sense, the api process is idling when waiting for requests and no cpu cycles are allocated to it. It seems that should be a general rule: idle processes don't incur charge. Say you receive a request on AWS deployed api, but your AWS deployed api makes an api search request to say SummoLogic, which takes 10mins to complete and return search results. In those 10mins AWS cpu is not allocated as the search api is waiting for a response, SummoLogic's cpu is doing the work, so you shouldn't get charged by AWS for those 10minutes..?

  • Well, that's not how it works. You are charged from the time your handler is invoked until it returns. When it returns we freeze the sandbox and nothing can run in there. While it is in the handler, even if your function is waiting for some external resource, the CPU is still allocated to you and you are charged for that time.

0

Thank you for the clarification, even if your process is in wait or ready state (not in running state) you get charged for the runtime that never ran. Kind of like renting a car, when the car is parked you still get charged. Does runtime charge only happed when code is deployed or also while developing, if you have AWS console open and you are typing commands there, do you also get charged for that time as well?

Boris
已回答 6 个月前
  • You can create many functions. You are only charged when you actually invoke them. SO as long as you are in the console writing the code, nothing happens. Only when you invoke the function, either directly by calling the Lambda Invoke API, or by invoking some other service that triggers your function such as API Gateway. Again, you are only charged from the time your handler is called until it returns (some exception with Lambda extensions, but not relevant for this discussion).

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则