In the land of cloud computing Amazon Web Services is king, with the platform’s slew of services, it’s hard to deny this claim. But today we shift our gaze away from AWS and towards the strongest competitor for the crown, Google Cloud Platform. I recently got to play with Google’s cloud platform, specifically Google Compute Engine (GCE), and was pleasantly surprised with it. GCE is the Infrastructure as a Service portion of Google Cloud and Google’s answer to Amazon’s EC2.

Setting up your instance

Setting up your GCE instance is quite simple:

  • Install the Google Cloud SDK, this provides you access to the “gcloud” command line tool.
  • In the management console create a new instance (Project -> Compute -> Compute Engine -> VM instances -> Create instance)
  • Name your instance
  • You can add meta data to your instance, useful if you want to pass custom values to startup scripts.
  • Choose if you want HTTP ports open in your firewall
  • Select Zone, where you want your data to be stored and used.
  • Select Machine Type, which determines the CPU and memory your instance will have.
  • Select the boot disk image. This determines what OS you want installed on your instance. You have the options of Debian, CentOS, openSUSE, Red Hat, Ubuntu, and Windows Server operating systems to choose from.
  • Select your disk type. You have the option of the “Standard Persistent Disk” or “SSD Persistent Disk”. The standard disk type is sufficient in most use cases, but the differences between the two disk types are covered in length in Google’s documentation.
  • I recommend unchecking the option to delete the boot disk when the instance is deleted. This will make it easier to upgrade your instance at a later time (this will be covered in detail later).
  • Set External IP. You have the option to set a static IP address or go with the default Ephemeral IP that Google provides.
  • Click Create to kick off the creation of your instance

Note: You can create your instance using the command line tool that comes with the Google Cloud SDK.

gcloud compute --project "black-tenure-866" instances create "app-server" --zone "us-central1-f" --machine-type "f1-micro" --network "default" --maintenance-policy "MIGRATE" --scopes "https://www.googleapis.com/auth/devstorage.read_only" "https://www.googleapis.com/auth/logging.write" --tags "http-server" --image "https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-1404-trusty-v20150128" --no-boot-disk-auto-delete --boot-disk-type "pd-standard" --boot-disk-device-name "app-server"

Accessing your instance

From the management console, you can simply shell into your instance with the push of a button. Clicking SSH on the VM instances page, opens a terminal in your browser and logs you into the machine.

You can also use the command line tool:

gcloud compute --project "black-tenure-866" ssh --zone "us-central1-f" "app-server"

Another option is to add your SSH public key to the instance. Click your instance’s name, to drill into the details page. Add the key in the SSH Keys section.

This is a very simple way to add users to your instance, all from the management console, with little to no fuss.

Configuring your instance

Managing firewall rules

  • In the VM instances page, click on the network name
  • This takes you the Networks section of GCE, where you can add or delete the firewall rules of the current selected network (if you just started this will be the default).

You can also add a new network, which is the equivalent to a Security Group in AWS.

Change machine type

This is where I feel GCE falls a bit short. If you have a machine type that is f1-micro, which is pretty small (1 CPU core and 600MB memory), and would like to increase it to a n1-standard-2 (2 CPU cores and 7.50GB memory), there is no intuitive way to do so. There is no “edit machine type” option, but it can be accomplished:

  • Delete the instance
    • Make sure you uncheck the option to delete the disk on delete.
    • The external IP may stay the same, but the internal IP will change.
    • SSH keys added through the console will be deleted and will have to be added again.
    • Save the details of the instance, you will need it later. You can run the following command to get all your instance details:
      gcloud compute --project "black-tenure-866" instances describe "app-server" --zone "us-central1-f"
  • Create a new instance, with similar details as the previous instance.
    • Specify the new machine type
    • Instead of using a new disk, use the previous instances existing disk

Monitoring your instance

GCE does a great job of showing analytics and logging in a user friendly manner.

  • VM Analytics - The VM Instances page shows CPU Utilization, Network Traffic, and Disk Traffic
  • Quotas - details the usage and limits of GCE’s resources
  • Operations - audit log of all operation requests performed on global resources, such as images, zones, networks, firewalls, kernels, and snapshots.
  • Google Cloud also offers a cloud monitoring service (Google Cloud Monitoring), which allows you to create alerting rules and alerts based on metrics, in a similar vein to Amazon’s Cloud Watch.

Pricing

When it comes to “On-Demand” pricing, GCE pricing is currently cheaper than EC2.

Google also bills all instances on 1 minute increments, with a 10 minutes minimum charge. This pricing model is far better than EC2 which rounds up to the hour. With GCE you essentially pay for what you use, and it’s more cost effective if you need to rapidly scale up momentarily to handle a spike in traffic.

Conclusion

It’s still too early to call Google Cloud Platform the usurper of the cloud computing throne. The platform doesn’t have nearly as many services as AWS. For what it lacks in services, though, it makes up in a very user friendly and clean interface. If all you need is to spin up a virtual machine, you will be hard pressed to find a cheaper and simpler option than Google Compute Engine.