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. If there is a lot of traffic it will add more containers containing the webserver.
Sounds great, but there’s a catch.
Cloud Run depends on the fact that your application should be stateless. 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 app.yml
file.
runtime: nodejs12
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 entrypoint command.
All the scaling is automatically done for you. And as a bonus, you can even store state information on the server.
This means that if you want to host an existing web application to the Google Cloud, the App Engine is probably your best bet.
Which service should you use?
If you have an application that is not stateless then you should go for the App Engine.
Also, 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.
Top comments (1)
thank you for explaining it so simply