App engine is regional, your application will get deployed across zones. It is important to remember that once deployed, you cannot change the applications region.
App engine is a good option for simple micro services.
If you are using one of the standard language like python, then you can use app engine standard. However, if you are using app engine flexible, you have to build the container using an image and use app engine flexible.
It is also important to remember that app engine standard will scale down to zero when there is no load but app engine flexible will run at least one instance and will not scale down to zero even if there is no load.
In App engine, there will be a file called app.yaml this is where we configure the runtime, Api version and other things like automatic scaling or manual scaling etc.. Or if you want to use app engine standard or flexible.
it is also important to note that you can only have one app engine in one project. you can have multiple services in the app and multiple versions in multiple services but at the root, the app engine is tied to a project and only one app can be deployed in a project.
Command | What it does |
---|---|
gcloud app deploy | This command deploys the application |
gcloud app browse | This command gives the URL of the App |
gcloud app services list | This command lists all the services present |
gcloud app versions list | This command lists all the different versions present |
gcloud app instances list | This lists the instances currently running. |
gcloud app deploy –version=v2 –no-promote | To deploy new version with the traffic still on old version |
gcloud app services set-traffic –splits=v2=.3,v1=.7 | to split the traffic between new & old versions once new version is deployed. |
gcloud app browse -s {name-of-service} | to get the url for a specific service |
gcloud app services set-traffic -splits=v1=.3,v2=.7 –splits-by random | To split the traffic between v1 & v2 randomly instead of using IP |
gcloud app deploy –region=us-central | to create the app in a specific region |
gcloud app deploy filename.yaml or gcloud app deploy –image-url | the default is app.yaml but the yaml file has a different name, we need to specify that. We can also specify the docker image url in case of app engine flexible. |
App Engine – Request routing
The url can be used to route to different versions or different services can be called. If you are using a custom domain, there would be a slight change in the URL’S
https://project_id.region_id.r.appspot.com {default service}
https://service-dot-project_id.region_id.r.appspot.com {Specific service in default version}
https://version-dot-service-dot-project_id.region_id.r.appspot.com {specific version of a service}
The Default IP splitting mechanism is using the source IP address. It can be modified to split using the cookie as well.
In case if you are using app engine standard, then you cannot SSH to the instances but if you are running app engine flexible, you can even ssh to the instances as well as copy files from the App engine to local disk
command | What it does |
---|---|
gcloud app instances delete {instance_name} –service=s1 –version=v1 | Deletes the instance |
gcloud app instances scp –service=s1 –version=v1 –recurse local_dir {instance_name}:remote_dir | Copy files to/from App engine flexible instances |
gcloud app instances ssh –service=s1 –version=v1 {instance_name} | SSH into the VM of an App engine flexible environment |
In the App engine, we can configure a cron job. It is done typically using a file called “cron.yaml” file. The Yaml file contains the url for the task & the schedule it has to run. This can simply be run by using the command “gcloud app deploy cron.yaml”