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
gefragt vor 6 Monaten192 Aufrufe
2 Antworten
0
Akzeptierte Antwort

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
EXPERTE
Uri
beantwortet vor 6 Monaten
profile picture
EXPERTE
überprüft vor einem Monat
profile pictureAWS
EXPERTE
überprüft vor 6 Monaten
  • 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
beantwortet vor 6 Monaten
  • 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).

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen