Businesses are building applications on the cloud to create opportunities and accelerate transformation while ensuring security, accessibility, and scalability. A suitable cloud computing platform is required to create these applications. Google App Engine is one such technology that allows you to build and host scalable web applications on a fully managed serverless platform.
The creation of multiple applications and domains in App Engine enables you to deploy multiple applications to a completely managed and serverless environment. It allows you to deploy directly from code and assign custom domain names to each application individually.
To understand the creation of multiple applications and domains in App Engine, let’s assume that there are five applications that have been developed. The applications are written in Go, Java, Node, PHP, and Python, which is the main application. These applications need to be deployed in GCP’s PaaS offering, App Engine.
Additionally, for these applications, two domain names have been purchased:
And these subdomains need to be assigned to individual applications:
So, how can we achieve this?
Let’s first take a quick look into how we deploy these five applications to App Engine.
In App Engine, we can create a single Application per project. This Application needs to be created in a specific region, which cannot be modified later. App Engine has Services to deploy multiple applications and codebases.
We can deploy multiple apps with their configurations as individual services in App Engine. Each service has its specific URL by which we can use to access it. By default, the default service is created when we deploy for the first time.
Some sample codes and steps to deploy them as services can be found here.
The service names created using the sample code:
Note that the service names can be alphanumeric strings.
Once the apps are deployed, they are available on these URLs:
Default service: https://<project_id>.<region_id>.r.appspot.com
Individual services: https://<service-name>-dot-<project_id>.<region_id>.r.appspot.com
With the apps now deployed as individual services, we have individual URLs where we can access these apps. However, we need to set up custom domains that can be used to route to specific services as well. Access to the DNS provider would be required for these steps.
Steps to add custom domain names for App Engine:
This process needs to be done for all the URLs that are mentioned at the start of this article. Once all the URLs are added, the screen appears in the below manner in the App Engine Custom Domain section:
You may also see a small loading icon, which shows that the Google Managed SSL certificates are being provisioned.
When the DNS changes are done successfully, the new URLs become accessible on HTTP. Test out all the URLs with HTTP.
You will notice that all the URLs point to the same default service.
To map each URL to a specific service, we will use a file called dispatch.yaml
The dispatch.yaml file is used to override the default request routing mechanism for App Engine. We can provide a map of specific URL patterns, and which service they need to be routed to.
The dispatch.yaml file for this example appears as given below:
dispatch:
- url: "www.medium-appengine-domain1.tk/*"
service: default
- url: "medium-appengine-domain1.tk/*"
service: default
- url: "go-app.medium-appengine-domain1.tk/*"
service: go
- url: "node-app.medium-appengine-domain2.ml/*"
service: node
- url: "java-app.medium-appengine-domain2.ml/*"
service: java
- url: "php-app.medium-appengine-domain2.ml/*"
service: php
We can deploy this file using the following command:
gcloud app deploy dispatch.yaml
Once this file is deployed, you can now test the URLs. They will be routed to specific services.
The creation of multiple applications and domains in App Engine provides us access to a completely managed infrastructure which is highly scalable and elastic. It also enables us to deploy applications developed in multiple programming languages without additional effort. The App Engine gives an infrastructure that manages the applications while ensuring network security and scalability.
Get in touch with us to build your cloud strategy and explore how Google App Engine can enhance your business capabilities.