Let’s say you want to deploy a web application that has a moderate amount of traffic. Not Amazon.com or SnapChat—just your average company website. You want the site to be available all the time, so it must be deployed for high availability. You want it to autoscale to meet spikes in demand. You also need some place to store the data, so you need a database.

Traditional Architecture Utilizing IaaS

Let’s consider a traditional Web development architecture. You have a Java or .NET web application running on Linux or Windows machines with a MySQL database. Since you want high availability, you need two web servers and two database servers running all the time. You need a load balancer. You would also set up an autoscaler to turn machines on and off to meet demand. The architecture might look similar to what is shown below.

So, what would this cost? Let’s assume 10 GB of storage, which is the minimum for the database, and n1-standard-2 machines for both the web servers and the database servers (these machines have 2 CPUs and 7.5 GB RAM). Adding in a small charge for the load balancer, this comes to about $300 per month.

This would handle a reasonable amount of traffic. Obviously, if you have lots of traffic and spikes in demand, the cost would go up. If your database was larger, the price would go up.

Cloud Native Architecture Using PaaS

Let’s say you alter your application to use Google App Engine and use Google Cloud Datastore for the data. Now the architecture looks like this.

App Engine automatically takes care of autoscaling, health checks, and load balancing for you. Datastore is just there and highly available. In both cases, there is nothing to manage.

So, what would this cost? App Engine programs shut themselves off when not in use and scale automatically when they need to. Let’s say you averaged 3 instances per hour. This allows for dead time when there are zero instances, and bursts of traffic when more start up. That would cost about $67 per month. Datastore has a free tier. To be consistent with the MySQL use case above, 10 GB of Datastore data, plus let’s say a million reads and a million writes would be 2 or 3 dollars a month. This comes to about $70 per month. That’s less than a quarter the cost of the IaaS solution above.

Obviously, if your app goes viral and you turn into SnapChat the cost will go up, but then you go public, raise $8 billion in your IPO, and buy Venice Beach, CA. We’re just considering the case of an average company website.

Let’s Go Serverless

The cool kids don’t write websites in Java or .NET anymore. Let’s say you rewrite your application using a JavaScript framework like Angular or React. Since the front-end code runs in the browser, you don’t need a web server anymore. Just deploy the website to a Cloud Storage bucket. However, your front-end needs an API at the server that it can call to save or retrieve data. Since you are programming in JavaScript, just use Cloud Functions to provide that API. As always, you need to store your data—let’s use Datastore for that. This architecture now looks like this.

So, what would this cost? The Cloud Storage bucket would be free because there is a 5GB free tier. Cloud Functions costs 40 cents per million requests, but you get 2 million requests per month for free. Uh, I’m going to go out on a limb and call that free. As before, if you assume 10GB of Cloud Storage and a million reads and writes, this might cost a couple dollars per month. If you add in some network traffic, maybe you’ll hit 5 dollars per month. Although, if you never go beyond a free tier, you may never get billed at all.

So, What’s the Moral of the Story?

Deploying your applications to Google Cloud Platform can be inexpensive, scalable, and highly available, if you do some work up front to take advantage of what is provided.

Want to learn more? Click here: Google Cloud Platform Training.

Please join my LinkedIn Google Cloud Student Resource Group.