samaspin
samaspin

Reputation: 2402

Why is Cloud Run serving responses from wrong region?

I have a Cloud Run instance running Django, both the GCP console and gcloud confirm the instance is deployed to europe-west1 region.

However, using a tool like https://www.site24x7.com/find-website-location.html ** Django seems to be serving responses from Mountain View, USA.**

This is not a transient issue, its come to light as I run a number of scrapers on this instance and on international sites they are receiving responses that are targeted to the US.

Upvotes: 1

Views: 641

Answers (2)

ahmet alp balkan
ahmet alp balkan

Reputation: 45196

@Kolban's analysis is correct.

All Google Cloud IPs (including the Compute Engine VMs) will seem like they're coming out of "Mountain View, CA, USA" regardless of the region they're running in. This is because they belong to the same global IP block that Google has.

This IP pool is also likely used by other Google products like Cloud Run, Cloud Functions, App Engine and Compute Engine as well.

Most probably, Google doesn’t dedicate certain IP ranges to specific regions, as Google’s IP blocks are meant to be routed to the nearest Google datacenter, then enter Google’s private network, and be routed internally.

My recommendation would be to not to use the IP address of a Cloud Run service (or a Compute Engine VM) to determine its region. This information is available inside the VM or container on the "metadata service".

Upvotes: 2

guillaume blaquiere
guillaume blaquiere

Reputation: 75715

On your location web site, simply enter the domain name run.app. You will find the same thing, Montain View, CA. In fact, when you register a domain, you put a location of this domain. Your website use this metadata to answer you a static answer.

However, to be sure, I ran a test

I deployed 2 services enter image description here

And I ran a test on both

> curl https://europe-west1-hello-<hash>-ew.a.run.app -s -o /dev/null -w  "%{time_starttransfer}\n"
0.081340

> curl https://us-central1-hello-<hash>-uc.a.run.app -s -o /dev/null -w  "%{time_starttransfer}\n"
0.175606

I'm located in France. Europe West 1 (Belgium) only 81ms. US central 1 (8000km from me) 175ms.

That's consistent!

Upvotes: 0

Related Questions