Google cloud storage egress high cost, how can I reduce it?

一个人想着一个人 提交于 2021-01-04 05:38:51

问题


I have an android/ionic app running on 28 smart TVs. this app show in the TV images and videos like promotions and other informative banners, this images are stored in google cloud storage are 78 images with total size of 300mb.

The app have the URL of the image and show it like a html web

<img src="googlecloudimageurl">

Every 10 seconds the googlecloudimageurl changes to show the next image like a slide, every 10 seconds the image is downloaded from a Google Cloud Storage URL that is in the 28 smart TVs that have the app.

In my Google Cloud bill I have:

Cloud Storage Download Worldwide Destinations (excluding Asia & Australia)
from 2019-10-01 to 2019-10-31
2.381,626 gibibyte price 272,10

So, my main question is that I'm trying to understand the high cost of 272 dollars and reduce it. Should I maybe use another solution instead of google cloud storage?


回答1:


The price you're seeing is the network egress pricing, documented here. For the first 0-1TB (excluding, perhaps, the first 1 GB under the free tier) the cost of egress to the internet is (depending a bit on where your data is) about $0.12 per GB. That gives you roughly the amount you're being charged.

Based on your description of the application, however, it sounds like you have an opportunity to be substantially more efficient. You're literally downloading the same data over and over again -- especially if you're reloading the image every 10 seconds- on average, you'll download the same image every 780 seconds -- just under 15 minutes.

So, the thing to investigate here is caching.

Option 1

The obvious opportunity for you is to see if you can just download all 78 images to each of the 28 TVs, once, and serve them from the local store. Likely also periodically checking for updates and refreshing as needed. I have no idea how much storage is available on the TVs, but this is a clear winner from a network cost perspective. To download 300MB once to 28 TVs, you'd pay only 0.3*28 = 8.4GB, which at 0.12/GB is only $1 (ever -- unless you have to update the images at any point).

Option 2

If you can't store them locally on the TVs (and periodically check for updates), the next thing might be to see if you can run a proxy that shares data near the TVs. Then, everything is again cached locally, but now you have to maintain the proxies.

An good alternative here, as suggested in the comments by @JohnHanley is to use one of the numerous small, cheap Linux box/appliances attached to the TV's HDMI port to show the slides instead of a smart TV app.

Option 3

Finally, you can look at using Cloud CDN. Given that Cloud CDN serves from the network edge, its egress costs are lower for any content that is a cache hit (which should be basically everything you are doing here).

Note that you will also need to configure an http load balancer in front of your bucket, as this is required by Cloud CDN. This is the middle of a tutorial that walks through the steps of adding a GCS bucket as a backend to a load balancer. If you haven't used a load balancer before, you'll want to walk through the whole thing.

This is still going to be reasonably expensive though, since you still have to pay for the same amount of egress (now at only $0.08/TB). I just did a quick estimate for CDN egress to north america for the same amount of bandwidth and about 7.3M requests (roughly 28 TVs * 30 days * 1 request each every 10 seconds). That came to just under $200. There's an additional fee for fills, but it'd be trivial in this case (maybe $0.02, assuming the data never changed). You will also need to pay for the load balancer that Cloud CDN requires, but since there is only 1 forwarding rule, this should only be about $20/month. So, maybe you can save $50-60 off your current network costs with this route.


If you can at all deal with local caching, that's certainly the way to go here given the relatively small size of the data compared to the network costs of egress.



来源:https://stackoverflow.com/questions/58845675/google-cloud-storage-egress-high-cost-how-can-i-reduce-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!