Long idol time using Google Cloud Function = High Cost

I have a mobile app that uses google cloud functions to call the OpenAI API in order to keep the api key secure. Everything works fine, but the cost is incredibly high while the cloud function waits for the OpenAI response. Basically, the cloud function is “on” in idol mode for a good 8-10 seconds every time it is invoked while it waits for a reply. This is costing me a ton in google cloud time, and I’m wondering if anyone else has come up with a simple solution to limit this expense?

1 Like

Indeed, it’s not optimal. Most serverless solutions will likely not be optimal. A low spec VPS with a good connection will probably be more cost effective. Heck, a raspberry would probably be enough.

Speaking of, (haven’t tried this yet), but have you considered something like cloudflare workers?

2 Likes

I’m trying to avoid building my own infrastructure (even in the cloud)…thus the whole using google’s infrastructure which I have nearly 100% confidence in terms of up time and whatnot. I haven’t looked into cloudflare yet…will do that now. Thanks!

1 Like