2
votes

When creating an http Google Cloud Function it seems that you are limited to the region of the project in the Google Cloud Console.

What if you want multiple regions for your Cloud Functions but want to have access to the same google services like storage, datastore, etc.? How would you set that up?

Otherwise, someone far from your region may get some latency.

2
I think google hold those resources multi-regionally, cloud.google.com/docs/geography-and-regions. You only need to care about the region of app engine and cloud engine. - MT-FreeHK

2 Answers

4
votes

You can deploy your GCF to multiple regions as Doug says, and obtain something like this:

However, there is currently no managed way to "Load Balance" around multiple regions (hence reaching the best region for you); this burden is currently on you (you need to implement some logic client-side).

I'm trying to understand internally if there's appetite to build this feature (internal number 142776307). Comment here if you're interested in this (use cases / impact).

1
votes

You can set the region of a function during deployment. According to the documentation, the gcloud command line argument is --region:

If you are using the gcloud command-line tool, you can specify the region by using the --region flag. For example:

gcloud functions deploy FUNCTION_NAME --region REGION FLAGS...

Where REGION is one of the regions listed above.

If you're using the Firebase CLI, there is also affordance for setting the region.

You can deploy a function to multiple regions, but each one will get triggered in response to any event, which is probably not what you want (except in the case of HTTP triggers, where the region is baked into the URL for that function).