Newbie: Can I control the IP address where code gets executed from?

78 views
Skip to first unread message

Omar Miah

unread,
Apr 17, 2018, 2:55:23 PM4/17/18
to Google App Engine
I'm learning to code for online market places like Amazon.
I want to make code to manage accounts - make listings, process sales, reply to customer messages and other things.

I need to be in control of where the code is seen as being executed from.
If a UK seller and code gets run by a server from the North Pole - then Amazon might block thinking it's a hack or something.
(Just made that up to illustrate my point.)

So, can I run the code so that it runs from a UK server for example?
Same for other countries, USA would need USA IP, France need France etc.

I'm not sure if my question makes sense. I'm assuming there IS an IP address attached to where the code is getting run from?

Code running would be PHP, but would like that to become Python later.

Thanks.

Fady (Google Cloud Platform)

unread,
Apr 17, 2018, 7:09:40 PM4/17/18
to Google App Engine

Hello Omar,


In general, using Google Cloud Platform, you may try hosting your application in two different ways. The first is by using Google App Engine where the idea is to focus on your code and build your application without worrying about the underlying infrastructure. However the infrastructure that is hosting your app is regional, and you have to choose the region before deployment (project creation). For example, if you choose to have your application in europe-west2 (London), then your customers in London will have faster response time than other customers from other parts of the world.  


The second approach is to manage your own virtual infrastructure through Google Compute Engine. For example, you can create as many VM instances as you wish in multiple regions, and run your application accordingly, load balance and autoscale  the VMs, use Cloud CDN, etc.


In both circumstances IP addresses are not the proper resources to determine where the underlying infrastructure is hosting your application ( VM instance for example). As a matter of fact, Google Cloud IP addresses are not specific to a region, and they are usually registered to be originating in the USA ( Mountain View) despite that the resource using it could be somewhere else. In other words, your customers can not determine the location of your resource from an IP address. I hope this answers your question.

Omar Miah

unread,
Apr 17, 2018, 8:05:36 PM4/17/18
to Google App Engine
Fady, thanks for the reply, immensely helpful in understanding.

The problem is Amazon - nothing else.
For code execution and all other factors - yes, I want fastest and best options.

But it's all about Amazon. For a UK user, I don't mind if the server is in USA - as long as the IP address that is given to Amazon 'appears' to be a UK one.

It's not Amazon as such - they're super helpful and nice.
It's the robot computers that will detect activity from Google's servers in North Korea and freeze the account for days, while the seller cries saying everything is OK - while banging their head against a wall. 

So...

1. Can I control the reported IP number?

2. For one user, can I repeatedly use the same IP number again and again?
The idea is that each user will have their own IP address.

Let me know what you think.

Thanks.

Navi Aujla (Google Cloud Support)

unread,
Apr 18, 2018, 3:04:58 PM4/18/18
to Google App Engine
Hi Omar, 

Public IP addresses are assigned to GCE VM instances from the available pool of External IP addresses, which can be reserved. These IPs are based on the regional basis, for example: If hosting VM instance is in europe-west1, then public IP assigned to the VM will be from the same region. However the DNS lookup for the IP assigned (ext) to the VM can map to US Mountain view location, because of the SWIP records. For more information, refer to this stackoverflow thread where one of our engineer has explained it in more detail. 

However currently, "App Engine does not currently provide a way to map static IP addresses to an application." "App Engine's current range of outgoing IP addresses are encoded in the sender policy framework (SPF) record of _cloud-netblocks.googleusercontent.com. You may need to recursively perform DNS SPF lookups to resolve the entire list of IP ranges."[1

To answer to your questions, currently, it is not possible to choose the specific external IP address of your choice from the IP pool, however you can reserve the IP address from the region's IP pool. For your second question, can you provide more details? Also, your use case and proposed architecture would be helpful to get better understanding in this case. 

FYI: You can check the list of currently available GCP location and regions. 

Omar Miah

unread,
Apr 18, 2018, 4:45:34 PM4/18/18
to Google App Engine
Navi

Thanks for the replies - so helpful.

I don't really have any more information about the architecture. The code is just an idea in my head at the moment. :)

One other question: if I fired off 100 instances of the code running in at 11.59am, will they all have the same IP address assigned?
It shouldn't matter - but it might! So best for me to know ahead of time.
If I offer a system whereby orders for users are sent at 12.00pm, then I would need to fire off all 1 minute earlier.

Navi Aujla (Google Cloud Support)

unread,
Apr 19, 2018, 1:54:21 PM4/19/18
to Google App Engine
Hello Omar, 

As a front end, you can set the load balancer and I would assume using managed instance group with autoscaling enabled which automatically add or remove instance based on the autoscaling policy settings and does not require manual intervention.  

Now, Instances within the instance group set as backend service behind the load balancer will have separate external IPs as same IP address cannot be used for all the instances, same goes for additional instances spin ups while autoscaling. However, load balancer is acts as front-end with reserved static IP address, for the requests coming in and forwards to the backend service. Here is more details on how HTTP(s) Load balancing works. 

FYI: External IP assigned and in use by the resource are not charged
Reply all
Reply to author
Forward
0 new messages