2
votes

If you use Firebase Hosting to direct requests to a Cloud Function via a rewrite, does that request traffic that "passes through" hosting get billed into Firebase Hosting GB transferred? (Ignoring the billing for the Cloud Function)

In other words,
Do Firebase Hosting function rewrites themselves cost money when requests come in?

To be clear,
Obviously, HTTP Cloud Functions cost money and have quotas. But, HTTP Cloud Function billing aside, does the traffic (ie the bytes) passing through the Firebase Hosting Rewrite get billed into Firebase Hosting billing?

To limit the scope of answers, the answer is either A or B:
A. $ for the function + $ for the request bytes passing through hosting.
OR
B. $ for the function + the rewrite doesn't cost anything.

2

2 Answers

2
votes

UPDATE:

The official answer is A.

I was shocked to discover this, so then I asked about other assumptions I had. I also found out that,

  • If Firebase Hosting has a rewrite to a function that is secured with IAM, then even the unauthorized requests are billed on GB Transferred when the function returns an "unauthorized" response. Even when the function itself is not billed for unauthorized requests.

  • If a function rewrite or file does not exist at a certain route, then you are billed on GB Transferred when Firebase Hosting sends a "Resource Not Found" response. Yes, sending the characters in a "Resource Not Found" response that you didn't implement is billed.

Quotes directly from official Firebase Support:

My Question:
"Does Firebase Hosting bill when sending the "Page Not Found" page when a resource is not found? I would have assumed the answer is an obvious no for that case, but since unauthorized cloud function invocations are billed, I don't want to assume anything."
Support Answer:
"Regarding the 'Page not Found', I've confirmed with the (Google Firebase) team that it is being billed/allocated to GB transferred/downloads."

"Regarding your original question, Firebase Hosting bills for the bytes that get served to end users. In the case of Cloud Functions, it does not matter whether it's a success or not."

"Yes, you will be charged both for Cloud Functions invocation, and Firebase Hosting data transferred to. However, if you cache the content in Firebase Hosting, cache hits are not charged to Cloud Functions."

0
votes

Yes.

When you host a website through HTTP Cloud functions, quotas are getting applied on that HTTP function. It can cost you extra money.

Check https://firebase.google.com/pricing.