How to use GCP API-Gateway for App Engine microservices? - google-app-engine

I have multiple services deploy on App Engine default environment. Now I want to create a API-Gateway to make the calling of the services easier to use in Frontend. Also I can then use the security provided by the GCP API-Gateway.
App Engine:
Service 1
Service 2
Service 3
API-Gateway
API-Gateway 1 --> containing all the endpoints for all services
The GCP docs for API-Gateway uses a single config file for an api and gateway. But when you have 20 services and each service has 10 endpoints you would have an huge config file
Questions:
Is API-Gateway the best way to use for App Engine microservices ?
Should something like dispatch.yaml routing be used for this case ?
What are best use cases to handle this problem in GCP ?

Related

Microservices with App Engine and API Gateway

I have several microservices hosted using GAE Stadard. Currently the UI communicates directly with each service. I'd like to setup an API gateway so the traffic will be routed to the correct service based on path. E.g. any requests starts with /products will go to service A, while /orders will go to service B.
Is it something can be done using Google Cloud, without having to develop a new routing service?
Thanks in advance
There is a New Feature in Beta for App Engine that allow you to setup and deploy an API gateway for your services, which is exactly what you want to do.
You can check details and a tasklist of how to set it up in this Documentation.

How to serve multiple gcloud service with one domain

I have multiple gcloud services running for different tasks. Some use functions, some app-engine and one is a compute engine machine.
How can I serve all of theme with one public domain?
I imagine some kind of mapping or routing like :
example.de/auth => function A
example.de/wallet => app-engine default service
example.de/user => cloud run service
...
I've red that cloud endpoints is the pendant to aws AWS api-gateway.
But as far as I understand I cannot apply a domain to cloud endpoints in general.
What can I use to build such kind of facade (example.de domain)?
Google Cloud Endpoints are a service that can be run in a docker image, GKE, or Cloud Run.
If you are running Cloud Endpoinsts as a service in Cloudrun then you can configure the custom domain for the the cloud Run service following This Guide which how to add a mapping to a custom domain.

GeoDNS routing on Google Cloud Load Balancer with Google App Engine as backend

We are looking to use Google App Engine for one of our low latency service. We are required to provide low latency service across the globe. Since Google App Engine is a regional service and there is no straight forward way to deploy it multi-regional. So, looking at Google Load Balancer to route at DNS level, but that also does not seems to be possible as load balancer not supporting App Engine as a backend service. Is there any other way to achieve GeoDNS routing in GCP for App Engine service.
There is not an direct way to achieve GeoDNS routing since App Engine is a regional service, as you said.
Read this feature request to have further insight on this. In the second comment they state the two possible workarounds, useful for both standard and flexible environments:
The workaround is how you mentioned, using a single project with a load balancer to route requests to Compute Engine instances in
different regions. Then have each Compute Engine instance act as
proxies to an App Engine project in each of the different regions
(where you would copy your code to each App Engine project).
It may be easier in the meantime to use Google Kubernetes Engine instead of App Engine for multi-regional application serving.
You could star the FR to support it.

Can Google App Engine make a http request to a Compute Engine instance within the same project without an external IP?

In App Engine I'd like to make http fetch calls to a web server running on an Compute Engine instance, created within the same Google cloud project, and I'm wondering if I can make such calls to the instance without enabling an external IP for it? Are App Engine and Compute Engine instances, from the same project, within the same network and can I call a Compute Engine instance by name from App Engine?
The best way to solve that in the short/medium term is to deploy the VM as a VM-based backend (we are accepting TT applications). You can deploy the VM backend as a different App Engine module of the app. Then you can urlfetch "mymodule.myapp.appspot.com" from the frontend and it will hit your VM without going through the public IP.
You can also serve your app straight from the VM backend. There you can load classes that are blocked by the normal App Engine sandbox (and well as have full access to all App Engine APIs!). The downside with VM backends is that we don't have auto-scaling yet.
This is currently unsupported. Communication between App Engine and GCE must go through the URLFetch API and use a public IP.

Google App Engine Backends not associated to any Frontend

I'm developing a Java app in GAE, which offers an API through Google Cloud Endpoints.
Basically it receives requests in the endpoints and uses a number of web services from different providers, stores some data and returns some data through the endpoints...
I understand that my app is conceptually a backend, because it doesn't provide any web page, but only the endpoints, don't you think so?
But there's no way to create only a backend, without being associated to any frontend app, is there? At least Google Plugin for Eclipse only allow you to "Generate App Engine Backend", from an existing app, and moreover this app must be an Android project...
I'm using it as a frontend and there's no problem, but apart from the conceptual issue, I've read that backends are kind of optimized to be backends, with more memory and CPU...
I think you're just confused because the Cloud Endpoints documentation uses the word 'backend' to refer to the entire cloud-hosted server implementation. It doesn't specifically refer to the use of GAE backend instances. Endpoint requests can be served by frontend or backend instances, based on how you set them up and the url being accessed.
From the App Ending docs:
"When an application is called to serve a web request, it must issue a response within 60 seconds"
"App Engine Backends are instances of your application that are exempt from request deadlines and have access to more memory (up to 1GB) and CPU (up to 4.8GHz) than normal instances."
So unless you're requests are doing something crazy, you don't need to use a backend. In the google-plugin-for-eclipse, "generate appengine backend" is talking about creating a backend for your android app... a server for your android app to contact (in this case your android app is the frontend and you're appengine app is the backend). In the example app you can remove the web side (index.html) to the appengine application and you'll have no web frontend. Index.html is using the gapi javascript library to make endpoints calls to your appengine service.

Resources