Google App Engine is one of the most powerful Platform as a Service (PaaS) in the market today. It’s easy to get started, easy to scale and makes it easy to integrate with other Google Cloud products. With Google App Engine Flex, developers are able to run .NET Core apps on Google App Engine without having to worry about setting up IIS and SQL Server.
As a developer, you’re not limited to .NET Core apps. Google App Engine Flex supports Go, PHP, Java, Python, Node.js, .NET, Ruby and more. If you want something custom, use Docker and specify your own Dockerfile. Unfortunately, if you’re not careful, you could incur higher costs because the default environment is just too much for prototyping an app in most cases.
In Azure, you are able to run prototype ASP.NET Core apps for free or low cost, but sometimes as developers we want to have other options for easily running our apps. Sure, there are options like AWS but GAE Flex is the simplest options to get from File->New Project->Deploy on a cloud platform in my opinion.
So what can we do to minimize the cost of prototyping on Google App Engine Flex?
Deploying a Default ASP.NET Core App
We’re going launch an ASP.NET Core app on App Engine Flex. The default app.yaml is below:
Deploy your app with the gcloud command:
gcloud app deploy
App Engine launches two n1-standard-1 VMs. These VMs are designed for production workloads and not necessarily appropriate for prototyping workloads. The default deployment configuration in the Google Cloud Pricing Calculator cost over $80.00 a month. This is very pricy for dev/prototyping work. Let’s see what we can do to reduce the cost.
Reducing The Number Of Instances
You can immediately cut the price roughly in half by launching with one instance instead of two. You can do this by enabling manual scaling and setting the instances to 1. Update app.yaml:
You’ll end up spending $45.00 from around $83.00. Good improvement but still a bit pricey for prototyping an application.
Using Smaller Instances
The price is reduced from $45.00 to about $23.00 per month. We can do better though.
Stop Dev Instances
Since you’re working on a prototype, you don’t need your instances running 24/7. App Engine deploys a new version every time and this makes traffic splitting and/or rolling back trivial. However, you probably don’t need these features for a prototype. Deploy your app using the following command (two dashes):
gcloud app deploy –version dev
When you’re finished working for the day you can stop your instance with the following gcloud command:
gcloud app versions stop dev
When you’re ready to start working the next day, just enter the following command:
gcloud app versions start dev
If you follow these simple steps, you will successfully reduce the cost of Google App Engine Flex from about $83.00 to about $20.00 per month. It’s not free but it’s much more affordable. What I like about App Engine is that you only have to modify the app.yaml to scale your app. When you’re finished working for the day, turn off your instance.