admin 管理员组文章数量: 1086019
Mobile app -----> Firebase Function
| ------------------> External API
| waiting...
| CPU billed?
| <------------------ External API Responds
Mobile app <----- Firebase Function Responds
In my 2nd gen Firebase Function, I am making a request to an external API. Naturally, that API will take some time to respond. My Firebase Function will return with a response after that API request completes.
My question is, will I be billed for CPU time while waiting on that external API? The CPU is not actively being used, so it would make sense if I was not billed. I asked Gemini and it strongly agrees with this point of view in this Gemini chat: (please scroll down to the latest question there, the beginning of the chat is about something else). Gemini thinks request-based billing means just this.
However, I'm not convinced and the graph here in Billable Instance Time makes me think that I'm actually billed for the CPU during that idle time where I do nothing on the CPU except waiting for the API to respond.
Does anybody have a definite answer to this? Am I billed the same as someone doing CPU-intensive task for merely waiting for a network response?
Mobile app -----> Firebase Function
| ------------------> External API
| waiting...
| CPU billed?
| <------------------ External API Responds
Mobile app <----- Firebase Function Responds
In my 2nd gen Firebase Function, I am making a request to an external API. Naturally, that API will take some time to respond. My Firebase Function will return with a response after that API request completes.
My question is, will I be billed for CPU time while waiting on that external API? The CPU is not actively being used, so it would make sense if I was not billed. I asked Gemini and it strongly agrees with this point of view in this Gemini chat: https://g.co/gemini/share/d37b5aed9c41 (please scroll down to the latest question there, the beginning of the chat is about something else). Gemini thinks request-based billing means just this.
However, I'm not convinced and the graph here in Billable Instance Time makes me think that I'm actually billed for the CPU during that idle time where I do nothing on the CPU except waiting for the API to respond.
Does anybody have a definite answer to this? Am I billed the same as someone doing CPU-intensive task for merely waiting for a network response?
Share Improve this question asked Mar 28 at 15:28 Gazihan AlankusGazihan Alankus 12k7 gold badges51 silver badges64 bronze badges1 Answer
Reset to default 1will I be billed for CPU time while waiting on that external API
Yes.
The CPU is not actively being used, so it would make sense if I was not billed
You are billed for as long as a function is in the middle of invocation, from the time it starts to the time it returns a response. The busy-ness of the CPU is never the issue - what matters is that the CPU is allocated and available to perform work during an invocation. The only time you are not billed for CPU on a given server instance is if there are no active requests for that instance (eventually allowing it to scale down).
Gen 2 functions improve on this by allowing multiple concurrent requests, so that they all share the same total billing time. You will want to read this documentation to better understand how it works. Specifically:
When setting concurrency higher than one request at a time, multiple requests can share the allocated CPU and memory of an instance.
See also:
- How does a Cloud Function instance handles multiple requests?
本文标签:
版权声明:本文标题:Firebase Functions, does waiting for external API to respond count towards billable CPU time? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744028495a2521065.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论