Like CGI scripts, it scales down really well though. I have an endpoint that is very important but only needs to handle a couple requests per hour. I wrote it as a Cloud Function and it's costing about $0.12 per month. Spinning up a super cheap VM that would sit idle most of the time would cost quite a bit more (plus time to set it up, deploy code to it, manage updates, etc).
$0.12/month seems expensive for such a low requirement? Is it because of the size of the function? Does GCP lack a free tier that would otherwise be free on a different platform? Not knocking your decisions. I just legitimately want to know where the cost comes from.
Yes, it requires a reasonably large amount of memory and runs for 40-50s per invocation. $0.12/month seems pretty reasonable to me. In our case, it also interacts with other GCP APIs, so the security model where we can just grant the Cloud Function service account granular access is extra convenient and would require extra engineering to duplicate if there were a free host somewhere that we could run the same code. GCP has a free tier and if that were the only thing we ran there, it would probably be covered. I really don't know about what's included in their free tier though because the other services we run on GCP put us well past whatever it might include.
Our total monthly GCP bill is in the five figures range, so it's included there if we need it. Ultimately, a very simple function running on Cloud Function is just way, way more reliable and "safe" for us than spinning up a VM, monitoring that, installing a full web server or CGI or Django/Flask setup to it, keeping it patched, managing deploys to it, etc. There's just fewer moving parts to break.
I wouldn't advise someone to spin up a key part of their infrastructure on Cloud Functions if they're not already using GCP for other things. But once you're there, it's a very useful part of the ecosystem.