user9773014
user9773014

Reputation:

Running One Instance of Google App Engine with frontend in nodejs and backend server in python

I'm getting my feet wet with GCP and GAE, also nodejs and python and networking (I know).

[+] What I have:

Basically I have some nodejs code that takes in some input and is supposed to then send that input to some python code that will do more stuff to it. My first idea was to deploy the nodejs code via GAE, then host the python code in a python server, then make post requests from the nodejs front-end to the python server backend.

[+] What I would like to be able to do:

just deploy both my nodejs code and my python code in the same project and instance of GAE so that the nodejs is the frontend that people see but so that the python server is also running in the same environment and can just communicate with the nodejs without sending anything online.

[+] What I have read

https://www.netguru.co/blog/use-node-js-backend

Google App Engine - Front and Backend Web Development

and countless other google searches for this type of setup but to no avail. If anyone can point me in the right direction I would really appreciate it.

Upvotes: 4

Views: 1542

Answers (1)

Dan Cornilescu
Dan Cornilescu

Reputation: 39824

You can't have both python and nodejs running in the same instance, but they can run as separate services, each with their own instance(s) inside the same GAE app/project. See Service isolation and maybe Deploying different languages services to the same Application [Google App Engine]

Using post requests can work pretty well, but will likely take some effort to ensure no outside access.

Since you intend to use as frontend the nodejs service you're limited to using only the flexible environment for it, which limits the inter-service communication options - you can't use push queues (properly supported only in the standard environment) which IMHO would be a better/more secure solution than post requests.

Another secure communication option would be for the nodejs service to place the data into the datastore and have the python service pick it up from there - the datastore is shared by all instances/versions/services inside the same GAE app. Also more loosely coupled IMHO - each service can function (at least for a while) without the other being alive (not possible if using the post requests).

Maybe of interest: How to tell if a Google App Engine documentation page applies to the standard or the flexible environment

UPDATE:

Node.JS is currently available in the standard environment as well, so you can use those features, see:

Upvotes: 3

Related Questions