Google Cloud Run: Automatically Scale Stateless Containers

Google Cloud Run

Modern software development relies heavily on containers as a portable, standardized method of packaging apps and their dependencies. A serverless platform called Google Cloud Run uses the power of containers to give developers a quick and effective way to install and operate their apps at scale.

Cloud Run offers a practical way to execute containerized apps without worrying about the underlying infrastructure, scaling up or down dynamically based on traffic. 

The article discusses the significance of Google Cloud Run, Cloud Run Services & Job, integration, and more.

Here’s everything we’ll cover:

What is Google Cloud Run?

Google Cloud Run is a platform that is fully managed and serverless, which means that it enables developers to run applications that are containerized without having to worry about the infrastructure that supports them. The capacity to grow automatically based on traffic and demand will enable developers to create and deploy stateless containers to the cloud.

Cloud Run supports any programming language that can be packaged as a Docker container. As a result, programmers may quickly deploy their apps to Cloud Run using the language or framework of their choice.

Cloud Run offers pay-as-you-go pricing, so programmers only pay for the resources they use and only while their application is active. The platform can dynamically scale up or down to fit demand, ensuring the service is always available and responsive. It is the perfect option for applications with unexpected traffic patterns.

The well-known open-source project Knative, which offers a standardized method to create, deploy, and manage serverless workloads on Kubernetes, is the foundation upon which Cloud Run is based. As a result, developers can benefit from Kubernetes’ scalability and flexibility without having to take care of the underlying infrastructure themselves.

Google Cloud Run Services and Jobs

The technology dynamically scales a container up or down based on incoming traffic when a developer delivers one to Cloud Run. This means that the application remains available and responsive at all times, even when there is a high volume of traffic. 

Your code can continue running as a service or as a job on Google Cloud Run, and the same infrastructure allows them to integrate with the other Google Cloud services.

  • Cloud Run Services: Stateless apps known as Cloud Run Services can be quickly deployed to the cloud because they are packaged in a Docker container. 
  • Cloud Run Jobs: Cloud Run Jobs are temporary tasks that can be carried out as needed without requiring underlying infrastructure management. 

Google Cloud Run Services

A stateless application that is packaged in a Docker container and can be quickly deployed to the cloud is referred to as a service in Google Cloud Run. 

Developers can use any programming language and framework when creating their services as long as the application can be put in a container. After the container is constructed, it may be quickly deployed to Cloud Run, where the platform will handle the rest.

Cloud Run services are made to grow dynamically according to demand, guaranteeing the application’s responsiveness and availability. The platform can scale up from zero to handle requests and back down to zero when there are no new requests, saving the user money. To increase the application’s security, Cloud Run services can also be set up to operate on a private network.

Google Cloud Run Services Features

  • Unique HTTPS Endpoints: Every service has a unique HTTPS endpoint on its specific subdomain under the * domain, which the platform makes available when a programmer deploys a Cloud Run Service. In addition to supporting WebSockets, HTTP/2 (end-to-end), and gRPC (end-to-end), Cloud Run controls TLS for you.
  • Built-In Traffic Management: Cloud Run Services has facilities for managing traffic distribution among several service instances. To implement a progressive rollout, you can send incoming traffic to the recent revision, return to a prior iteration, or split traffic across many modifications simultaneously. This function guarantees that resources are used effectively and that users get a consistent experience.
  • Fast Request-Based Auto-Scaling: Cloud Run Services dynamically scale up or down according to the incoming requests. This indicates that the service can withstand high traffic loads and remain accessible and helpful to users.
  • Public And Private Services: Both private and public services can be launched using cloud-run services. Public services can be accessed from the internet, while private services can only be accessed within a VPC network. 

Google Cloud Run Services Use Cases

Following are some of the most popular use cases of Google Cloud Run. 

  • Microservices and APIs: Cloud Run Services are ideal for developing and deploying microservices and APIs that interact using HTTP or gRPC, a GraphQL API, or a REST API. This enables more efficient utilization of resources and ensures that the service is both accessible and user-friendly.
  • Websites and web applications: Web applications and sites that were created with various programming languages and frameworks can be hosted and scaled using Cloud Run Services, while you can use your preferred stack to make your web application, connect to your SQL database, and produce dynamic HTML pages.
  • Streaming data processing: Processing streaming data, such as data input, transformation, and analysis, can be done using Cloud Run Services, such as updates from Eventarc and Pub/Sub push subscriptions can send notifications to Cloud Run services.

Google Cloud Run Jobs

Google Cloud Run provides running jobs in addition to running services. A short-lived activity that can be carried out instantly in Cloud Run without the need to manage the underlying infrastructure is known as a job. 

Using event-driven processes like a Cloud Pub/Sub topic or a Cloud Storage bucket, jobs can be started manually or automatically. The container shuts down automatically after finishing the task, saving the user money.

Job with one task

One container instance can be started by a job to operate your code; this is a typical technique to run a tool or program. But you can also simultaneously launch several identical, distinct container instances or an array job.

Jobs with multiple tasks

Array jobs provide a quicker approach to handling jobs that can be divided into numerous independent tasks.

For Instance, Analyzing 1,000 photographs sequentially to resize and trim them will take longer than analyzing them all simultaneously using several container instances.

Google Cloud Run Jobs use cases

Following are some significant use cases of Google Cloud Run.

  • Script or Tool: In a serverless environment, developers can utilize Cloud Run to run temporary scripts or tools, such as batch data processing, cron jobs, or custom scripts, while to do database migrations or other maintenance operations, you can use a hand.
  • Array Job: Array Job enables developers to run several jobs concurrently, each with a separate set of parameters, to process enormous amounts of data or carry out repetitive operations, such as processing all items in a Cloud Based bucket in a highly parallelized manner.
  • Scheduled Job: You can utilize Cloud Run to execute scheduled tasks at predetermined intervals. It lets you regularly generate and transmit invoices or store an XML file containing the outcomes of a database query and upload it every few hours. This can help automate recurring actions that must be carried out regularly.
  • Machine-Learning Interference: Cloud Run Machine learning models can be run using jobs in a serverless setting. Developers can deploy their models as tasks and package them in containers, enabling on-demand inference without needing to manage infrastructure.

How to deploy to Google Cloud Run

Deploying a single container in the Google Cloud Run is not that daunting, just follow the below-mentioned steps to deploy a single container. 

Step 1: Log in to Google Cloud Run using your registered account information. 

Step 2: Click on the Create Service option to view the full Create Service Form.

Using the form:

  • Choose Deploy One Pevision of an existent container image.
  • Click Test with a sample container
  • Choose the location where you wish your services to be accessible from the Area pulldown option.
  • Choose the Accept all traffic choice and Permit unauthenticated invocations in the corresponding table on the Configure how well this application is activated form.
  • To deploy the test container image to Cloud Run, click Create and then wait for the deployment to complete.

You have successfully deployed a container that answers arriving HTTP requests to Cloud Run. When there are more requests than your container can manage, Cloud Run automatically scales it out; when there are fewer demands, it scales back in. 

Google Cloud Run integrations 

Google Cloud Run integrates with the more extensive Cloud infrastructure, allowing you to create fully functional apps, following are some of the significant integrations of Cloud Run.

Data storage

You save and access data from your apps using Cloud Run, which connects with several Google Cloud storage services, including Cloud Storage, Cloud SQL, and Firestore.

Continuous delivery

Thanks to Cloud Run’s integration with Cloud Build and Container Registry, your apps will have a complete end-to-end continuous delivery pipeline.

Background tasks

Cloud Run enables the use of Cloud Tasks or Pub/Sub to conduct background tasks, enabling asynchronous processing or task scheduling at a later time.

Private networking

Cloud Run enables you to install your services on a private network as an extra security measure.

Logging and error reporting

By integrating with Cloud Logging and Cloud Error Reporting, Cloud Run offers a central area to monitor and debug the logs and faults of your application.

Google Cloud APIs

You may leverage pre-made machine learning models in your apps by integrating Cloud Run with several Google Cloud APIs, including Cloud Vision and Cloud Translate.

Service identity

Using Google identities and groups to control access to your services and resources is made possible by Cloud Run’s integration with Cloud IAM.

Google Cloud Run pricing 

You will only be billed by Cloud Run for the services you utilize, adjusted to the closest 100 milliseconds. Be aware that each resource has a free tier, and the sum of the assets listed in the price table will represent your final Cloud Run bill.

Several applications may share container instances’ allotted CPU and RAM when concurrency is set to a value greater than one demand at a time. Resources within Google Cloud’s exact location are free for network egress (for example, traffic from one Cloud Run service to another Cloud Run service).


Stateless containers can be run serverless on the robust platform Google Cloud Run in a highly scalable and safe setting. Developers can quickly launch their apps with Cloud Run without handling the infrastructure’s maintenance. 

The platform scales up or down automatically depending on the traffic volume, resulting in cost savings and effective resource use. Cloud Run is also cost-effective for running containerized apps at scale due to its pay-per-use pricing structure.

Cloud Academy offers a comprehensive Google Cloud Platform Training Library, where you can learn about GCP certifications and labs. If you’re interested in learning about Google Cloud Run, you can do hands-on using Build and Deploy a Container Application with Google Cloud Run lab. This lab requires a basic understanding of Docker, but it is not compulsory.

Frequently Asked Questions (FAQs)

What is Google Cloud Run vs. App Engine?

Cloud Run is a serverless container platform that is fully managed by Google. At the same time, Google App Engine is a higher-level platform-as-a-service (PaaS) that abstracts the underlying infrastructure and focuses on ease of use for web application development.

What is the difference between Google Cloud Run and Google Cloud Functions?

With Google Cloud Functions, you can run code in response to events when Google Cloud services triggered them. Google Cloud Run is built for stateless containers that can be installed and run fast in response to incoming requests.

What is the AWS equivalent of Google Cloud Run?

AWS Fargate, a fully managed container platform that enables you to install and run containers without addressing the underlying infrastructure, is the AWS equivalent of Google Cloud Run.

Cloud Academy