Choose the right Compute service on Google Cloud Platform

Nirav Kothari
GDGCloudMumbai
Published in
6 min readJun 8, 2020

In the recent years the cloud service offerings have grown immensely, so is the cloud acceptance by the organizations. This has come true because organizations have started realizing the benefits of using cloud services. And since more and more organizations have started turning to cloud, providers have become more aggressive in their offerings. They are providing multiple services for computing, storage, networking, big data solutions and ML services. It is up to the application owners to choose the best suited services for their application and that makes their life more challenging.

In this blog I will try to give some insights on how one should go about choosing the compute service for their application. Although this blog is written in Google Cloud Platform context, the concepts remain applicable to all cloud providers.

GCP offers 5 types of compute services to deploy your applications. Each service is designed to serve specific type of needs for application deployment. These services vary in terms of amount of operational overhead and the control over deployment. The pyramid below gives the gist of the control in developer’s hand vs. self managed deployment.

Google Compute Engine

This is Infrastructure as a Service (IaaS), which lets you create the virtual machines with hardware (RAM, CPU, Disks etc.) of your choice, choose the OS (even custom OS), configure the network, define auto-scaling policies etc. with maximum control over each and every resource. But it comes at a cost of high operational management.

Pros:

  • Flexibility to choose hardware — CPU, GPU, RAM, Disks
  • Flexibility to choose OS including customized OS
  • Supports live migration during maintenance
  • Supports live disk resizing
  • Supports Auto scaling
  • High availability and low latency can be configured by deploying instances at multiple regions and configuring load balancing
  • Pricing benefits — Sustained use discounts, Committed use discounts, Peemptible VMs
  • Gives highest control

Cons:

  • Need to manage VMs on your own
  • Need to define auto scaling policy, load balancing, high availability manually
  • Live scaling up/down (change in CPU, RAM) not possible. It is possible after shutting down the VM
  • Need skills and more time to deployment

Google Kubernetes Engine

This is a managed Kubernetes engine running on the Google infrastructure for deploying, managing and scaling the containerized applications. GKE provides a clean interface to manage the cluster and deploy your workloads.It is the same technology that Google uses for its production services.

Pros:

  • Run Kubernetes on GCP infrastructure
  • Supports hybrid cloud and multi cloud
  • Handles auto-scaling, auto-repair, auto-upgrade
  • Smart defaults to reduce configuration parameters
  • Take full advantage of containers
  • Most appropriate choice for highly dynamic scaling

Cons:

  • Application should be containerized
  • You need to manage cluster yourself
  • Need skills to manage Kubernetes clusters

Google App Engine

This is a Platform as a Service (PaaS) offering from GCP. It lets developers focus on application development while deployment is handled by GAE. Developers can deploy their apps from any of the standard environments like Java, Python, Node.js, .NET, PHP, Go, Ruby etc. If you want to deploy app with some other platforms (say C++) or a custom environment (say Python 1.6), then that is supported by submitting the docker image (flexible environment). Scaling of the application will be automatically handled by the platform. Inherently GAE is regional.

Pros:

  • No-ops platform (Simply upload your build)
  • Load balancing is automatically implemented
  • Auto scaling handled by platform. Virtually infinite scaling.
  • High availability and durability handled by deploying redundantly across multiple zones in the region
  • Standard sandbox runtime for multiple platforms and customized platform using docker

Cons:

  • Don’t support OS customization unless we use docker
  • Can not scale in multiple regions.
  • Pricing based on uptime of the instances
  • Not suitable for workloads

Google Cloud Function

It’s fully managed serverless platform which handles deployment activities like provisioning infrastructure, setting up operating systems and runtime environments on its own and leaves developer with only the coding efforts. Platform provisions an instance whenever a request comes in and no instances are running. The subsequent requests are handled by the same instance until an idle time when instance is brought down. The service offers multiple triggering mechanisms like HTTP triggers, Cloud Pub/Sub Triggers, Cloud Storage Triggers etc. Auto-scaling is handled by the platform.

Pros:

  • Event driven computing
  • No-ops platform (simply upload the function to execute)
  • Serverless platform (dynamically provision resources)
  • Auto scaling, Auto update
  • Pricing based on request processing time

Cons:

  • Limited choice of programming environment
  • No control over OS
  • due to cold start, low latency not possible specially for first request
  • No access to disks for local storage
  • Multi-region functions are not possible

Google Cloud Run

It’s a new managed service from Google Cloud to run containerized applications in serverless fashion. It scales the application based on the number of incoming requests without the need for Kubernetes engine. It provisions the instances when request comes. Since it runs containers, virtually there is no limitation on number of supported environments.

Pros:

  • No-Ops and Serverless platform
  • Auto scaling based on the traffic
  • Pay only for request execution time

Cons:

  • Does not support orchestration and flexibility like GKE

Selection Criteria

  1. GCE provides the maximum control over the application, resources, network and storage; at the same time also achieve scaling, resiliency, low latency etc. But lot of these have to be manually managed. If you are migrating your on premise VMs and would like to migrate to cloud, then GCE is the option.
  2. GKE is a good option if your application is/can be containerized. The platform will give you control over resources, network, storage with levers for auto scaling, auto update, fault tolerant etc. GKE is also a good option if you are considering multi cloud or hybrid cloud options. Although GKE comes with smart defaults and easy clean interface, there is a bit of learning curve involved around the concepts of Kubernetes engine.
  3. If you just want to focus on the application development and do not want to pay attention to deployment then GAE, GCF (Google Cloud Functions) or Cloud Run are the options to consider. These platforms support auto scaling and resilience.
  4. Cloud functions are usually a good choice for light weight computing for example an event processing or a quick data processing etc. It can be used in applications where low latency is acceptable specifically in cold start scenarios.
  5. If you are developing a full fledged application then Cloud Functions may not be useful instead Google App Engine can be considered.
  6. For Microservice architecture, Cloud run and GKE are usually good options.
  7. If the the incoming requests are sparse and cold start is acceptable, then Cloud run should be chosen over GKE to reduce the cost
  8. If you expect the traffic from all over the globe, then deploying multi region app and load balancing plays a important role and GCE and GKE does well in this situation.

Here is a quick flow diagram / decision tree that can help you choose the right product on GCP..

Choose the right compute service — Flow diagram

Final Words:

Apart from the criteria mentioned above, factors like pricing, security and available skill set also matter in design decisions. Many a times, after carefully examining all the criteria, developer may face situation where more than one options are applicable for their application deployment, in such scenarios they end up going with their gut feeling often arising out of experience.

In the next blog I’m going to explain how to Choose the right storage for your apps in GCP.

--

--

Nirav Kothari
GDGCloudMumbai

#Developer #SolutionArchitect #NLP #ML #DataMining #IoT #Automation #GoogleCloud. Actively managing @GDG_Cloud_Mumbai