What is Google App Engine?
App Engine is a PAAS Service (Platform as a Service). It implies that you just deploy your code, and this service does everything else for you. For instance, if your application turns out to be successful, App Engine will spin up more instances to deal with the increased volume.
- Google App Engine is a fully scalable service means it will automatically spin more instances if the traffic goes higher and decrease the instances once the traffic decreases.
- You will be charged only for the resources you really use, It means that you will be billed for the Instance-Hours, Transferred Data, Storage, etc your app really used.
- But the only problem is, you can create your application in only given runtimes Python, PHP, Java, NodeJS, .NET, Ruby, and **Go, Whereas Google Compute Engine provides you infrastructure in the form of a Virtual Machine. You have total control over those VMs and you can use any runtime in VMs.
Types of App Engine
- Google App Engine — Standard is like a read-only folder in which you upload your code. Read-only means there are a fixed set of libraries installed for you and you cannot deploy third-party libraries at all). DNS / Sub-domains etc are so much easier to map.
- Google App Engine — Flexible is like a real file-system where you have more control as compared to the Standard App engine, you have write permissions, but less as compared to GCP Compute Engine. In Flexible App Engine, you can use whatever library your app depends on.
Compute Engine Vs App Engine
- Compute Engine is similar to a virtual PC, where you would deploy any website and database. You will manage everything, you have control of installed disk drives. If you deploy a website, You are in charge of setting up DNS, etc.
- GAE Standard is quite difficult because you can use only a certain set of libraries, you cannot use any third-party libraries.
- In Google App Engine, you don’t manage the operating system of any of the underlying software. You only upload code (Java, PHP, Python, or Go), and it just runs.
- Simply, GCE is the way to use Google Data Centers virtually.
- In GCE you have to manually configure your infrastructure to handle scalability and load balancing by using AutoScaling and Load Balancer.
App engine saves a lot of headache, but it has few drawbacks also:
- It is more expensive but it also has a free quota that GCE doesn’t have.
- You have lesser control over infrastructure, that’s why certain things are not possible.
- Login into GCP Console.
- Starting Cloud Shell.
- Creating an Application directory.
- Creating the Main function.
- Defining requirements/libraries.
- Defining Runtime.
- Deploying the application
Creating a Google App Engine application:
- Click on the hamburger icon on the top left corner
- Click on App Engine
- Click on Cloud Shell icon, on the top right corner.
- Create a directory for your application using command mkdir whizlabs-appengine
- Go inside your directory using command cd whizlabs-appengine
6. Create a file name main.py and Open it in a text editor using the command nano main.py
7. Enter the given code in main.py to return Welcome to Whizlabs.
8. Create a file name app.yaml to mention your runtime and Open it in a text editor using the command nano app.yaml
9. Enter the runtime as runtime: python37
10. Create a file name requirements.txt to mention your dependencies and Open it in text editor using command nano requirements.txt
11. Enter the dependencies as Flask==1.1.1
12. Now, to deploy your application on AppEngine use the command gcloud app deploy. If it prompts for the region, please select us-central1
13. If it prompts for authorization, Click on Authorize
14. Prompt will appear, press y to continue.
15. Your application is now deployed.
16. Use command gcloud app browse to get URL for your application
17. You will see the URL as the output, copy and paste it into a new tab of your browser. You can see your final output.
Completion and Conclusion:
- In this lab, you have deployed an application on App Engine.
- You have created a function returning Welcome to Whizlabs in Python runtime.