Do you want to build applications in the cloud but have no idea where to start? This series will walk you through building a “Hello World” Node.js application on virtual machines (VMs), containers (Kubernetes), platform-as-a-service (PaaS), and function-as-a-service (FaaS) offerings on Google Cloud Platform (GCP).
Just a few months ago, before joining Google, I also had no idea where to start with Node.js and GCP. To prepare for my interview, I watched most of the GCP Next 2017 talks, including Brian Dorsey’s Deciding between Compute Engine, Container Engine, App Engine, which inspired me to go and build something across the Google Cloud computing stack. To make this exercise more fun (and also to make sure I could manage it within the time constraints of a single weekend), I timed things and took notes. I found it very helpful both in terms of getting a feel for GCP as well as boning up on the fundamentals of web application development (hello 2018!). Today, I want to share some of my interview prep notes with you. If you are building your first web application or are generally interested in getting up and running with Node.js, you are in the right place! By the end of this post, you’ll be equipped to write a “Hello World” web application across the GCP compute stack: Google Compute Engine, Google Kubernetes Engine, Google App Engine, and Google Cloud Functions.
So, where do I run my code?
(Short answer: it depends… ) Here’s a condensed version of Dorsey’s GCP Next 2017 talk:
Generally speaking, it boils down to the following three criteria:
- Level of abstraction (what you want to think about).
- Technical requirements and constraints.
- Where your team and organization are going.
Depending on the problem you are trying to solve, technical constraints can pull you down the stack. For example, if you need a very specific kernel, you might be down at the base layer (Compute Engine). The following article offers a set of constraint-based questions to help you navigate the fundamentals: Choosing the right compute option in GCP: a decision tree.
What is Node.js?
- Asynchronous means first-class support for asynchronous operations (compared to many other server-side languages where you might have to think about async operations and threading — a totally different mindset). It’s an ideal fit for most cloud applications, where a lot of operations are asynchronous.
- And there is also npm, the world’s largest collection of free, reusable code. That means you can import a lot of useful functionality without having to write it yourself.
Pretty cool, huh? I am convinced!
On your marks… Ready, set, go!
We’ll start with Compute Engine and VMs first, and then move up the levels of compute service-abstraction ladder, to Kubernetes Engine and containers, App Engine and apps, and finally Cloud Functions. As a reminder, this is not a tutorial but recall of my journey (if you decide to follow along, please be sure to read the whole section before lifting commands).