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

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南