App engine in Google Cloud Platform (GCP)
What is App engine in GCP?
Types of App Engine environment in GCP
- Standard: In this version of App engine we don’t have the flexibility to SSH into the instance. It is on demand which might scale down to zero instance as well.It supports following programming language
- Flexible: We can manage the server infrastructure including scalablity feature.: It supports all the programming language and also support below
- Custom Runtimes
In App engine it creates a container of whole code and gets that running. It supports Python 2.7/3.7 |Java 8 |PHP 5.5/7.2 |Go 1.9/1.11 |Node.js 8
By default flexible app engine starts with 2 instance (for high availability reason but more resource means more expense 🙂 If you want to get it running only one instance then use the
service: proxy runtime: nodejs env: flex automatic_scaling: max_num_instances: 1
Features of App Engine
- Fully managed: Don’t need to think for infrastructure just use it.
- Secure: Google’s security in place. Even you can’t create new file on same server through code until you have proper privilege through service accounts.
- Support for popular languages: You can see the list of the languages for which its supported.
- Traffic spliting: You have feature to split real time traffice percentage to different versions.
- Monitoring, Logging and Diagnostics: In built stackdriver integration which gives great support for monitoring, logging and diagnostics
- Application security: Its provides HTTPS with firewall rules by default at no additional cost.
- Service Ecosystem: It provides ecosystem for different services all can be of different languages.
Application deployment in APP engine
gcloud app deploy
In order to run this command, you need to take care few things.
You project should be configure properly on GCP SDK (use command gcloud init for same)
Make sure you have app.yml file present on the root of the project and its well written including scaling and others (You can use any file name like my-custom-file.yml but in this case your command would be gcloud app deploy my-custom-file.yml)
In case you have any dependency then composer/any dependency file should be there and it should have all the dependencies properly declared.
Application scaling in App engine
1.Dynamic : Which starts up and shut down on need basis
2.Resident : Which runs all the time and improve system performance.
Both dynamic and resident instance instantiate the code included in app engine service version
There are three types of scaling in App Engine.
Manual : Where instances will be resident instances. It will keep on running irrespective of load level. Can either running or stop.
Basic : Where Services use dynamic instances. Here instance is created when the application receive the request. And turn down if application gets idle. This is ideal for the work that is intermittent or driven by user activity. Can either running or stop.
Automatic: Where Services use dynamic instances. It creates the instances based on application metrics (e.g., request rate, response latency, minimum idle instances, minimum resident instances etc.) . This is always running.
By default app engine instances gets charged hourly basis. But you can send limit by setting a spending limit.
Why App Engine is not best for containers
App Engine is good if you have only one container.
Application is not portable anymore (or require changes to be made)
If you want stateful containers you can’t do with App engine flex.
Difficult to manage complex micro services under it.