Choosing the Right Hosting Service on Google Cloud Platform for your Application

Which execution environment best suit your application needs on Google Cloud Platform

Leonardo Lima
Google Cloud - Community
4 min readNov 9, 2020

--

Google Cloud Platform offers a wide range of options to run your code on. In this article, we will see every service features, use cases, and pricing, and you decide which one fits the needs of your application and the level of control over the infrastructure you want.

Let's compare Cloud Functions, Cloud Run, App Engine, Cloud Dataflow, Compute Engine, and Kubernetes Engine (GKE), side by side.

TL;DR

  • Cloud Functions: serverless, fully managed, event-driven, for lightweight applications.
  • Cloud Run: serverless, fully managed, event-driven, for stateless containers.
  • App Engine: serverless, fully managed, highly scalable, for any kind of application.
  • Cloud Dataflow: serverless streaming and batch processing for data processing pipelines.
  • Compute Engine: custom CPU/RAM/GPU options to run anything on VM.
  • Kubernetes Engine: managed Kubernetes environment for containers.

Cloud Functions

Functions is an event-driven, fully managed, serverless, and highly scalable service, that can integrate lightweight services with your application. It’s ideal for microservices that requires a small piece of code to quickly process data related to an event.

If your code it’s a webhook, IoT data stream, HTTP endpoint or need integration with an AI service, functions is for you. Priced how long your application runs and the number of times it’s invoked. It has support for Node.JS, Go, Python, and Java.

Cloud Run

Cloud Run is a fully managed serverless platform for stateless Docker containers, and since we are talking Docker, you can run whatever you want inside it. Invocable via HTTP requests and can be integrated with Anthos.

You can have all everything Docker offers and with two commands, you have your application in production. Priced how long your application runs and the number of times it’s invoked. Cloud Run lets you expose only one port from your container, so have that in mind.

App Engine

For when you need multiple pieces of functionality in a single place and want to deploy your entire application. You just need to fill a YAML file and Google does the hard work for you. Also is easy to set up with other GCP services.

For highly scalable serverless applications. Supports Node.js, Java, Ruby, C#, Go, Python, PHP, or Docker. Pricing scales with your app’s usage. Great for mobile applications, seamless integration with Firebase.

If you wondering which serverless option better suits you, check this flowchart made by Google to help you:

font: https://cloud.google.com/serverless-options/

Cloud Dataflow

If you have a website, mobile app, or IoT devices, usually data coming from these systems is not often in a convenient or effective format. If you need to capture, analyze, and enrich these data, that’s where Dataflow comes in.

Dataflow is a serverless service designed for streaming and batch processing that execute data processing pipelines. A pipeline is a process that read, transform, and write data. It distributes the processing tasks to multiple virtual machines so they can process different chunks of data in parallel.

It supports Apache Beam SDK, so it’s Java or Python. If you use another language, consider another service. Since it’s a serverless service, you don’t have control over its infrastructure, and you pay per use.

Compute Engine

It’s the infra for Gmail, YouTube, and Google’s search engine. Runs customizable VMs and gives us more control over our infrastructure. It supports pre-defined or custom machine types, with CPU and RAM options. There are three type os pre-defined machines:

  • General Purpose: for general servers, website hosting, and databases.
  • Compute Optimized: for high performance compute like games or single-threaded applications.
  • Memory Optimized: for memory analytics and large databases.

You can also add graphical processing units, for intensely computational workloads like machine learning and data processing. You can run a different operating system and it has support for Docker containers. Pricing for Compute Engine is based on per-second usage of the machine types, persistent disks, and other resources that you select for your virtual machines.

Kubernetes Engine (GKE)

GKE provides a fully managed environment for Kubernetes to deploy, manage, and scale your containerized applications. The GKE environment consists of multiple machines (Compute Engine instances) grouped together to form a cluster.

Any Kubernetes use case applies for GKE, like microservices orchestrated by K8S. Cluster management fee of $0.10 per cluster/hour applies, worker nodes accrue compute costs until a cluster is deleted.

That's it! I hope this overview helps you decide which service fits your application needs. Feel free to follow me on GitHub and connect with me on LinkedIn!

--

--

Leonardo Lima
Google Cloud - Community

Computer Engineering student, Golang and Python developer, robotics and astronautics enthusiast, and open source defender