Compute Choices – VMs and the Google Compute Engine
In the cloud world, the most hands-on of these approaches is not really an option—you are not going to actually own the machines, and physically maintain them. That is the whole point of switching to the cloud—that the cloud provider manages scaling for you and allows you to pay as you go. But a cloud equivalent of this approach still exists—you could provision a large number of virtual machines (again, these machines are virtual, not physical), and run your app on all of these. You'd be able to log in to these machines, and you'd have to manage scaling up or down (by provisioning more or less VMs). The cloud provider is still providing you with very valuable services—you can autoscale your groups of VMs, you can have your VMs stay live during system maintenance, and so on. These services are collectively called Infrastructure-as-a-Service (IaaS).
In this chapter we will:
- Explore Google Compute Engine (GCE) which serves as Infrastructure as a Service provision of GCP.
- Learn how to create and manage GCE VMs along with its various aspects like disk type and machine types.
- Demonstrate using GCE VMs via running a webserver on it.
You could also easily go further. You might decide that you just want to write code—not deal with any provisioning of machines or networking or Ops. The cloud provider will allow you to write your code and deploy it without worrying about the underlying systems—virtual or physical. All that you know is that your app is available as a service—most likely as an HTTP endpoint that clients can hit using RESTful API calls. The cloud provides complete isolation from the infrastructure autoscaling, load-balancing, traffic-splitting—all of this is managed for you. Such a service is basically a platform on which you write your code, and forget about the rest. These services are collectively called Platform-as-a-Service (PaaS).
Let's draw a line with IaaS at one end, and PaaS at the other. The leading cloud providers—Amazon AWS, Microsoft Azure, and Google Cloud Platform—all offer the entire range of compute options, from IaaS to PaaS.
In addition to these, there are a couple of other approaches worth discussing—containers and SaaS:
- Containers lie somewhere in between IaaS and PaaS and involves the use of portable, lightweight images of your app—these lightweight images are called containers. Docker is a pretty common container format, and the GCP has a great orchestration framework called Google Kubernetes Engine (GKE) to run app containers on managed clusters. But that will be dealt in more detail in the later chapter.
- Another approach, further to the right of PaaS, would be Software-as-a-Service (SaaS). In our preceding web app example, Heroku acted as an example of a PaaS offering, while Shopify was an SaaS offering. It probably is fair to say that Microsoft Azure is currently far ahead of the other two in SaaS, because it makes very powerful software such as Office 365 available to users. IaaS reduces the burden of DevOps, PaaS virtually eliminates it, and SaaS reduces the burden of development.
The preceding line is a general representation of the compute choices out there, but on the GCP, there actually are five specific options. None of these really involve SaaS, except for very limited use cases, so let's leave that out for now. The offerings on the GCP are shown as follows:
If you have an infra background, these five choices might make perfect sense to you, but even if you do not, never fear, we'll talk about each of them. Throughout the course of this chapter and the next, we will describe each of these five compute options. This chapter focuses on the first—Google Compute Engine (GCE), which is basically a service to provision and work with virtual machines on the cloud.
GCE is a prototypical IaaS use case. What you need is a set of machines, placed at your disposal to set up in exactly the way you want. Configuration, administration, and management would all then be your responsibility. While this might sound like an on-premise data center, there are two crucial differences:
- The VMs are not running on hardware bought by you—rather, you just provision them whenever you need them and delete them when you're done.
- Several powerful infra services—autoscaling groups of VMs, load-balancing, the importing of external images, and so on—are provided by the cloud platform. This is why GCE is an IaaS solution.
In this chapter, we will get you familiar with GCE by covering the following topics:
- Creating, customizing, and modifying VM instances
- Block-based storage (local SSDs and persistent storage), which can be attached to your VMs
- Load balancing, start up scripts, and disk images that allow you to make optimal use of your VM instances