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
전문가
검토됨 한 달 전
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).

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠