Cloud Run vs App Engine
Should you use Google’s Cloud Run or Google’s App Engine for your next project?
What is Cloud Run?
In a nutshell, you give Google’s Cloud Run a Docker container containing a webserver. Google will run this container and create an HTTP endpoint.
To deploy to the Google Cloud you should build a Docker container image on your local machine. Then, you should upload this container to Google Cloud.
gcloud auth configure-docker
docker push grc.io/PROJECT-ID/IMAGE
And finally, you can deploy the pushed container with the following command.
gcloud run deploy --image gcr.io/PROJECT-ID/IMAGE
All the scaling is automatically done for you by Google. This sounds great, but there’s a catch.
Cloud Run depends on the fact that your application should be stateless. This is because Google will spin up multiple instances of your app to scale it dynamically.
If you want to host a traditional web application this means that you should divide it up into a stateless API and a frontend app.
What is App Engine?
With Google’s App Engine you tell Google how your app should be run. The App Engine will create and run a container from these instructions.
For example, to host a Node project on Google’s App Engine, I can simply create the following
entrypoint: node build/server.js
To deploy it to the App Engine I can run the following command.
gcloud app deploy
The App Engine will build a Docker Image with the
nodejs12 environment and run the
Similarly to Cloud run, your application should once again be stateless.
Which service should you use?
Deploying with App Engine is super easy. You simply fill out an
app.yml file and Google handles everything for you.
However, with Cloud Run, you have more control. You can go crazy and build a ridiculous custom Docker image, no problem!
In my opinion, Cloud Run is made for devops engineers, App Engine is made for developers.