Back-ends made easy: Google App Engine
Consider you have an amazing web application that does a super awesome job, and you want to reveal it to the world! Chances are, you might not own enough resources to buy and maintain a server wherever you are, and hence, using the cloud would probably be your best choice.
A lot of services are provided by the cloud, and to be honest, the cloud console itself might be really intimidating!
If you have played around with Cloud before, you might have encountered the following terms: Infrastructure as a Service (IaaS), Platform as a Service (PaaS), and Software as a Service (SaaS).
If you are not new to these terms, the first solution that will come to one’s mind is creating a virtual machine (VM) with suitable hardware configuration, installing the necessary dependencies. Then you enable a web server on that instance and run your app.
But here’s where problems arise: -
- What if you don’t know how many people will use your app?
If we assume that few people will use it and allocate fewer resources (such as CPU, RAM) to the virtual machine, and if there is a sudden rise of users, then the number of requests to be handled by the server will skyrocket, causing your app to crash :( - Now, if you allocate surplus resources for the virtual machine, your app will work fine and would be able to withstand high traffic. But if not many people are using it, then you might waste your money shelling out on resources that you don’t use much, since the traffic would be less.
- To handle the above two problems, you would need to set up a complex feature, called a “load balancer” for your virtual machine. But what if you are not aware of the necessary technical stuff required? All you have is a piece of code that works on your computer, and what if you don’t exactly know how to make it work on a remote computer, miles away from your place?
Wouldn’t it be amazing if there exists a solution to all these problems!
Enter Google App Engine!
App Engine, part of Google Cloud Platform (GCP), addresses the above problems. It is a “serverless” platform provided by GCP to host your back-end applications in the fewest clicks and commands.
When we say “serverless”, it doesn’t mean that no servers are involved. Your apps do run on a server, but they will be managed by the cloud service provider (in this case GCP), so that you (a.k.a the customer) need not worry about it at all. You just need the code.
Obviously, App Engine comes under Platform as a Service, where the information about the hardware infrastructure (such as virtual machines) are abstracted from the user and are taken care of by GCP.
Now, the process of presenting your app to the world (or “deploying” in technical terms) requires only three major steps: -
- Add a small configuration file (named ‘config.yaml’) to your code repository, where you will specify some information about your code (such as run-time environment, entry point).
- Sign in to the GCP console and upload your code files there.
- Using the code and configuration files; type a few commands, select the geographical location of the server and that’s it! Easy peasy, lemon squeezy!
App Engine supports popular runtime environments such as Python, Node.js, Go, Ruby, and the good old PHP.
Why App Engine?
There are several reasons why you might prefer Google App Engine over Google Compute Engine (Where you create VMs): -
- Very little stuff to worry about:
The creation, management, and running of servers and handling of virtual machine instances for the servers get done in the background for you, without any intervention. The only part you need to manage or worry about is your code. - Scalable and very fast:
Depending on the traffic, the app automatically ‘scales’ itself. That is, depending on the incoming traffic for your app, new instances automatically get created if the traffic increases and vice versa, and again this is also entirely managed by GCP itself. - Pay only for what you use:
Billing for using App Engine is also based on the usage of the application and not fixed, thereby saving you money. In some cases, scaling to zero is also possible — if your app is inactive and no traffic is present, then not a single penny is charged. This can really help you cut down costs, and ensure that none of your money or resources are wasted. - Security on the go:
The app you deploy on App Engine comes with a firewall and an SSL/TLS certificate on your custom domain without any additional charge, so you need not worry about the security.
Anatomy of an App Engine Application
The parts/components of an App Engine Application can be explained briefly with the following illustration:-
Your app comes under a single application resource, which is subdivided into services, versions, and instances.
- Services:
Your app can be divided into different parts called services. For example, APIs for your app could be a service, while, managing data in your database or maintenance tasks can be another service. Services can communicate with each other. Each service has its own source code and configuration files native to the app. An application must have at least one service, and a maximum of five services can be created for an application. - Version:
Each service can have one or more versions to fulfill your requirements. Multiple versions can be created for testing and development purposes, leaving the production deployment intact. Or, the incoming traffic could also be distributed among multiple versions of a service. - Instances:
Each version of service runs on one or more instances, which are increased or decreased automatically as per the load (scaling).
More details can be found here: -
An Overview of App Engine (google.com)
App Engine Flavors: Standard and Flexible
GCP provides two variants of the App Engine — App Engine Standard and App Engine Flexible.
- App Engine Standard: The standard version of the App Engine is scalable to zero, supports specific versions of popular programming languages, can be deployed in seconds, and can be scaled up and down almost instantly.
- App Engine Flexible: The flexible version gives more control over the runtime environment, supports Web Sockets and third-party binaries, and runs applications in a ‘containerized’ way.
More information on these variants can be found here: -
Choosing an App Engine environment | App Engine Documentation (google.com)
Conclusion
App Engine provides a nifty way to deploy back-end with ease, which makes it suitable for web applications and back-end for mobile applications. It is also cost-effective and requires less technical intervention, compared to its alternatives, such as virtual machines or containers.
Excited? Try out the App Engine here, and hope it suits you well!