Get on the Node.js Express to Google Cloud Functions
by Doug Rehnstrom

What is Google Cloud Functions?

Cloud Functions is a serverless environment for deploying Node.js applications. It is completely no-ops; you don’t have to provision or manage servers. It is inexpensive; it costs 40 cents per million requests, but the first 2 million are free.

Triggers

Cloud functions run in response to triggers. A trigger could be a change to a Cloud Storage bucket, a message sent to a Pub/Sub topic, or a request to a URL.

There are many examples. Monitor a bucket and when a picture is uploaded to the bucket, use the Vision API to label the picture. Or, monitor a Pub/Sub topic and when a message comes in, process it and send it to BigQuery.

Cloud Functions are Microservices

A microservice is a service that does one thing. So I got to thinking, why can’t my micro-service be a web application? That’s just one thing.

Node.js Express

If I were going to build a Node.js web app, I would use a framework called Express. Node.js Express is similar to Python Flask or ASP.NET MVC.

Express allows you to define routes. Routes are URLs that point to functions that return data. One route could be a page request which returns HTML. Other routes could define API calls that return JSON data. In the end, it’s the same thing. In response to an HTTP request, run some code and return a string.

There are just a couple tricks you need to know to deploy your Express app to Cloud Functions.

Do this tutorial. It walks you through creating an Express app. Once the Express app is built, it shows you how to expose it as a JavaScript function and then deploy it to Google Cloud Functions.

Be Careful Though

When your app goes viral, after 2 million requests, you will have to pay 40 cents every time another million requests come in!

Happy coding!

Comparing Architecture Costs on Google Cloud Platform
by Doug Rehnstrom

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.

 

Preparing for the Google Cloud Architect Certification – Getting Started
by Doug Rehnstrom

 

Cloud computing is all the rage these days, and getting certified is a great way to demonstrate your proficiency.  

The Google Certified Professional - Cloud Architect exam itself is very effective in making sure you are a practitioner, not just someone who memorized a bunch of terms and statistics. This is a true test of experience and solution-oriented thinking.

Here are some tips for preparing.

 

If you are new to Google Cloud Platform (GCP)

Some think cloud computing is just virtual machines running in someone else’s data center. While that is part of it, there is a lot more. Being a competent architect requires a broad understanding cloud services.   

To get an overview of the products offered by GCP, go to https://cloud.google.com. Spend a couple hours exploring the links and reading the case studies.

 

There’s no substitute for getting your hands dirty

Go to https://console.cloud.google.com, log in with your Google or GMail account, and then sign up for the free trial. You will get a $300 credit that you can use to learn GCP. This credit is good for a year.

Once you have an account, do the following labs (don’t worry if you don’t understand everything).

 

Take a Class

The first class to take is a 1-day overview titled Google Cloud Fundamentals: Core Infrastructure.

To help defray the cost, when you register for the course, use the promotional code DOUG and you will get in for $99 dollars.

You can also take this course for free on Coursera, https://www.coursera.org/learn/gcp-fundamentals.

The second course is Architecting with Google Cloud Platform: Infrastructure. Come to the first course, and I will make sure you get a big discount on the second one too!

Soon we will also be releasing two new Google Cloud Certification Workshops. Stayed tuned...

 

Next Steps

I’ve reached my word count for one post. Get these things done and I’ll follow up with another in a little while. 

Let me know how you are doing, doug@roitraining.com.