When to use Google App Engine Flex vs Google Cloud Run

Google App-EngineApp Engine-FlexibleGoogle Cloud-Run

Google App-Engine Problem Overview


I want to deploy containerized code using one of Google's serverless options. From what I understand Google has two options for this:

  1. Google App Engine Flexible Environment
  2. Google Cloud Run (in beta)

I've watched the 2019 Google Next talk Where Should I Run My Code? Choosing From 5+ Compute Options. And I read Jerry101's answer to the general question "What is the difference between Google App Engine and Google Cloud Run?".

To me it basically sounds like Cloud Run is the answer to the limitations of using Google App Engine Flexible Environment.

The reasons I can think of to choose App Engine Flexible Environment over Cloud Run are:

  • Legacy - if your code currently relies on App Engine Flex you might not want to deal with moving it
  • Track record - App Engine Flex has been around for a while in general availability and in that sense has a track record, whereas Cloud Run is just in Beta

But those are both operation type considerations. Neither is a concern for me. Is there a technical advantage to choosing App Engine Flex over Cloud Run?

Thanks

Note: The beta Serverless VPC Access for App Engine is only available for the standard environment as of this question posting April 2019, not for Flex, so that's not a consideration in the question of App Engine Flex vs Cloud Run

Google App-Engine Solutions


Solution 1 - Google App-Engine

Pricing/Autoscaling: The pricing model between GAE Flexible Environment and Cloud Run are a bit different.

  • In GAE Flexible, you are always running at least 1 instance at any time. So even if your app is not getting any requests, you’re paying for that instance. Billing granularity is 1 minute.
  • In Cloud Run, you are only paying when you are processing requests, and the billing granularity is 0.1 second. See here for an explanation of the Cloud Run billing model.

Underlying infrastructure: Since GAE Flexible is running on VMs, it is a bit slower than Cloud Run to deploy a new revision of your app, and scale up. Cloud Run deployments are faster.

Portability: Cloud Run uses the open source Knative API and its container contract. This gives you flexibility and freedom to a greater extent. If you wanted to run the same workload on an infra you manage (such as GKE), you could do it with "Cloud Run on GKE".

Solution 2 - Google App-Engine

I'd actually suggest that you seriously consider Cloud Run over App Engine.

Over time, I've seen a few comments of a "new" App Engine in the works, and it really seems that Cloud Run is that answer. It is in beta, and that can be an issue. I've seen some companies use beta services in production and others wait. However, if I am going to start a new app today - it's going to be Cloud Run over App Engine Flex for sure.

Google is very deep into Kubernetes as a business function. As Cloud Run is sitting on GKE - this means that it is indirectly receiving development via other teams (The general GKE infrastructure).

Conversely, App Engine is on some older tech. Although it's not bad - it is "yesterday's" technology. Google, to me, seems to be a company that gets really excited about what is new and what is being highly adopted in the industry.

All this said - when you wrap your services in a container, you should be able to run them anywhere? Well, anywhere there is a container platform. You can front your services with something like Cloud Endpoints and you can deploy on both App Engine and Cloud Run - swap back and forth. Then, at that point, the limitations might be the services that are offered. For instance, Cloud Run currently doesn't support some items, like Cloud Load Balancing or Cloud Memorystore. That might be a blocker today.

Solution 3 - Google App-Engine

Short story: Appengine is something real, relatively stable. Cloud Run is pretty much just a draft/idea, very unstable.

Long story: Being in alpha/beta Google Cloud Run may suffer many changes. If you are old enough you might remember how dramatically Appengine pricing has changed. It promised a CPU/RAM based pricing, then it decided that's not "possible" or at least not very profitable and moved to a VM based pricing, then they shipped a decent appengine release(Appengine Flex or whatever name it had at that time) but also increased the price again by adding a minimum instance model. Not to mention the countless APIs/breaking changes or the limits changes.

Cloud Run is based on gVisor which has some limitations so depending on the language/library you use and what you do, it may break(or just Google's implementation may break) at some point and there is nothing you can do (i.e. patch the system) and it will ruin your productivity and potentially your business. You may have a look on its current issues.

Free advice: Even if you choose Appengine or Cloud Run avoid proprietary APIs/services such Google Datastore. They may ruin your business. Pricing, APIs and limits will change. There is no real open source or paid alternative so your code is not portable. Your code is pretty worthless outside of Google cloud.

Disclaimer: I've been burned by appengine changes and datastore lock-in so my opinion may be biased.

Solution 4 - Google App-Engine

I have a ML model with REST API interface as a micro service. When I tried to run with Cloud Run, it deploys but just does not work. I had to switch back to App Engine Flexible Env.

Cloud Run (fully managed) currently (Jul 2020) has RAM limitation of 2GB. For better hardware I should go for Anthose with GKE infra. But this has min instance needs of at least 4 instances to properly work. Mine being a tiny application I settled for App engine Flexible environment. Though autoscale settings required min 2 instances, in early days it could be managed with manual scaling and 1 instance as limit.

EDIT: As on Aug 22 2020, the RAM limit is 4GB and number of cores is 2, for fully managed GCP cloud Run.

Solution 5 - Google App-Engine

Main difference is background tasks.

In cloud run, everything kicks off by a request, and once that request completes, the instance won't be up up any longer.

App Engine also gave you some built in freebies like memory caching, but I don't think that's true of App Engine flex.

For a straightforward HTTP API, the differences are negligible, and you can get some of the things that App Engine gives you with other GCP products (Cloud Scheduler, Cloud Task).

You can check this video out for a comparison and demo on cloud run: https://www.youtube.com/watch?v=rVWopvGE74c

Solution 6 - Google App-Engine

App Engine Flexible, focus on "Code first", developer-focused, App Engine app was made up of multiple services, you really didn't have to do any kind of naming when deploying your applications.

Characteristics of the GAE flexible environment :

  • It is not possible to downscale to ZERO
  • Source code that is written in a version of any of the supported programming languages: Python, Java, Node.js, Go, Ruby, PHP, or .NET
  • Runs in a Docker container that includes a custom runtime or source code written in other programming languages.
  • Uses or depends on frameworks that include native code.
  • Accesses the resources or services of your Google Cloud project that reside in the Compute Engine network.
  • Maximum request timeout: 60 minutes

Cloud Run is a managed compute platform that enables you to run containers that are invocable via requests or events, everything is a service, whether it's an actual service or an application with a web interface, so consider its use as the deployment of a service rather than an appplication.

Characteristics of Cloud Run :

  • It is serverless: it abstracts away all infrastructure management
  • It depends on the fact that your application should be stateless.
  • GCP will spin up multiple instances of your app to scale it dynamically
  • Downscale to ZERO

Solution 7 - Google App-Engine

You can use below url to get difference between Cloud Run and App Engine. Hosting Options

Some times many reason to use App Engine over the Cloud Run is, Cloud Run doesn’t Background processes. It response time also 15 mins only.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionhlpView Question on Stackoverflow
Solution 1 - Google App-Engineahmet alp balkanView Answer on Stackoverflow
Solution 2 - Google App-EngineBrian McBrideView Answer on Stackoverflow
Solution 3 - Google App-EngineMihaiView Answer on Stackoverflow
Solution 4 - Google App-EngineIshwara BhatView Answer on Stackoverflow
Solution 5 - Google App-EnginejavabroomView Answer on Stackoverflow
Solution 6 - Google App-EngineTiago MediciView Answer on Stackoverflow
Solution 7 - Google App-EnginePooja LaadView Answer on Stackoverflow