Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

"Received bytes" chart for API does not correlate with API logs. Excecive billing. Please help :(

I have deployed a pretty simple REST API, which is a backend for another simple Angular application.
I have noticed the increased billing for "Network Internet Data Transfer". When I checked the logs for API sent and received bytes, I saw that on average "Received bytes" is 5 times higher than "Sent bytes" which is strange. Based on this logic, the Angular application sends request API with 5 times more data than API returns data to the front-end. I have checked the networking and all payloads, and it does not make any sense.
Here is an example of a chart. I was making a random click in the Angular app, to trigger API calls so the log would be generated:

ArtemBondar_0-1709933317065.png

The chart spiked at received bytes at 295kb/s at 2:31pm
The log for API looks like this... it's all but just GET requests, and the size of each request is about 1kb. I have calculated that made about 30-40 calls per minute, so the amount of traffic has to be around 40-50 kb per minute.

ArtemBondar_1-1709933833749.png

How come I see the "Received bytes" spiking up to 300kb per second? And this is all GET requests, which don't have a payload. So the "Received bytes" should not show almost anything for the GET calls.

As a result of this weird behavior, I am seeing a spike in billing for "Internet Data Transfer Out North America to North America". I understand that once I have more users of this service, my billing will be crazy...
Here is my billing chart. On March 6, it's when the API was deployed and was more or less actively tested with UI altogether in the cloud. The previous billing from March 1 to March 5th includes other APIs that I run on the cloud, as it does not have billing for "Internet" at all. Pretty significant difference

ArtemBondar_2-1709934225345.png

Would be very appreciative for any insights.
Why do I see the spike in "Received bytes" and billing for usage of "Internet" and how else could I debug this to understand where is it coming from.

Thank you!

 

 

 

Solved Solved
0 2 321
1 ACCEPTED SOLUTION

Okay, I have found that inbound traffic is not billed, so it's not a concern.
The billing spike because of the outbound traffic, and I found the way to optimize applications.

View solution in original post

2 REPLIES 2

Some updates on this, I hope someone will be able to share ideas on how to debug.
I tried to send API requests using just Postman. A series of GET requests.

ArtemBondar_0-1710258346856.png

In the log, the request size is 1.2kb, the response is about 1kb.
So my request size is just 20% more on average than response, and this is most likely because of the bearer token.

But why in the dashboard I see the number for "Received Bytes" is 5 times more then "Sent Bytes" for the API?

Would be appreciated for any ideas or suggestions.

 

Okay, I have found that inbound traffic is not billed, so it's not a concern.
The billing spike because of the outbound traffic, and I found the way to optimize applications.