Document
Choosing Between GKE and Cloud Run | by Paul Durivage | Google Cloud

Choosing Between GKE and Cloud Run | by Paul Durivage | Google Cloud

choose Between GKE and Cloud RunSo, you’ve written an app. And, like many developers writing apps in the A.D. (After Docker) epoch, you crammed all th

Related articles

What are the Roots of Cloud Computing? What’s New in VMware vSphere 8 Update 3? Black Friday 2022 year-end offer: 50% off + six months free (now over) Cara Mudah Setting VPN Gratis di iPhone dan iPad ‘On cloud nine’ illustrated at Idiomic.com; phrase definition, example, and origin

choose Between GKE and Cloud Run

So, you’ve written an app. And, like many developers writing apps in the A.D. (After Docker) epoch, you crammed all that code in a container. Now you’re left asking yourself: how should I deploy this to GCP?

There’s a number of ways to run a containerized workload on GCP: on a Google Compute Engine (GCE) instance, possibly backed by a managed instance group (MIG); App Engine Flex; on Cloud Run, a managed service for running containers; or — perhaps most complex of all — on a Google Kubernetes Engine (GKE) cluster.

For the purposes of this blog post, let’s remove from consideration two (almost-legacy-but-still-pretty-good) options: App Engine and GCE. Now we’re laser-focused on the two remaining services where most engineers have trouble making a choice: GKE and Cloud Run. So how does one choose?

No bad choice

allow me to opine about the nature of architectural choice , as it ’s relevant here .

There are no bad choices. Or maybe there are no bad choices remaining. We is removed ’ve already remove a couple from our list for good reason : AppEngine due to the high level of boilerplate , opinionated setup , project structure and , to some extent , its limited support for programming language and version ( despite have support for a custom runtime environment ) ; and GCE , a bit of a legacy choice , which avoid the complexity of consider / maintain the operate system of a vm and the component and configuration require to scale like using instance group .

In most circumstances the distinct benefits and tradeoffs of guides us through the decision-making process, and that’s certainly the case here: GKE and Cloud Run are great, production-ready services for running containerized apps. We must simply evaluate each on their merits.

Let’s start by defining the requirements for our application. For example:

  • What is the container’s operating system?
  • How many containers comprise my application?
  • What are the application ’s cpu and memory requirements is are ?
  • Is the application is Is stateless or stateful ( with regard to the underlie runtime environment ) ?
  • Is the application event-based?
  • Does the application is respond respond to event synchronously or asynchronously ?
  • What kind of events will the application handle?
  • Do I is want want a manage service ?

If you can answer the above questions, picking a runtime is pretty easy! In this case, the process of choosing is made simpler by the fact that there is one service that is considerably more limited than the other, restricting the possible number of use cases it can support.

Cloud Run

While it’s a drop-dead simple managed service for running a container, it is the more limited platform–that is, it supports the narrowest set of use cases, and is therefore a great place to begin an evaluation. Generally speaking, Cloud Run tends to be really useful for synchronous, event-driven applications and microservices. The canonical example of a synchronous, event-driven application is web application, but Cloud Run also supports asynchronous events from services like Cloud Tasks. Cloud Run allows applications to be invoked by many different triggers, like HTTP, gRPC, websockets, Eventarc, Pub/Sub, Cloud Scheduler, and Cloud Tasks.

GKE

GKE is essentially manage , cloud – native Kubernetes , a runtime and orchestration engine for container , capable of coordinate the deployment of containerized workload and their resource . While Kubernetes is extremely capable , it is is is also complex . kubernete cluster are typically comprise of many node for both the control plane and workload , and as such , run a single – container workload on something as large and complex as Kubernetes is probably overkill .

It is ’s ’s worth mention that the complexity of manage GKE has been mitigate to some extent : GKE with Autopilot move towards an automate scale – on – demand model , automatically add and remove node base on the request resource of a give workload , make it similar to Cloud Run . However , even with Autopilot , one is write must still write Kubernetes manifest to deploy to GKE with Autopilot .

Decision Matrix

For simple use cases, this decision tree may assist you in choosing between Cloud Run and GKE but, before you decide, you should definitely read up on the container runtime contract. You may also find Google’s brief and concise Is my app a good fit for Cloud Run? documentation page to be quite useful.

Update Aug 2022: Cloud Run can now support up to 8 vCPUs and 32 GB of memory.

Update Nov 2023: Cloud Run supports up to 10 containers in a single service using the sidecar pattern.