What Is Cloud Run in Cloud Computing?
On This Page
What do you want to do?
Quick Definition
Cloud Run lets you run your code in a container without managing servers. It automatically starts your container when traffic comes in and shuts it down when it is idle. You only pay for the resources you use, like CPU and memory, while your code is running. This makes it a simple and cost-effective way to deploy web applications and APIs.
Common Commands & Configuration
gcloud run deploy my-service --image us-docker.pkg.dev/my-project/my-repo/my-image:latest --region us-central1 --platform managedDeploys a new service or updates an existing service with the specified container image from Artifact Registry to the managed Cloud Run platform in us-central1.
Tests knowledge of deployment command structure and the --platform flag to differentiate between managed Cloud Run and Cloud Run for Anthos.
gcloud run services update-traffic my-service --to-revisions my-service-00001=10,my-service-00002=90Updates traffic routing for a service, sending 10% of traffic to revision 1 and 90% to revision 2, enabling canary deployments.
This command is frequently used in exam scenarios to test understanding of traffic splitting and canary releases in Cloud Run.
gcloud run deploy my-service --image gcr.io/my-project/my-image --concurrency 50Deploys a service with a concurrency setting of 50, meaning each container instance can handle up to 50 simultaneous requests.
Concurrency is a key parameter for optimizing resource usage and is often tested in the context of scaling and cost management.
gcloud run services update my-service --min-instances 2 --max-instances 10Sets the minimum number of container instances to 2 (always warm) and the maximum to 10, controlling both latency and cost.
Min and max instances are common exam topics-min instances remove cold starts, max instances cap cost and prevent runaway scaling.
gcloud run services add-iam-policy-binding my-service --member='allUsers' --role='roles/run.invoker'Grants unauthenticated access to a Cloud Run service, making it publicly accessible over the internet.
This is the exact command used to allow public access; forgetting to set this role results in a 403 error. Frequently tested.
gcloud run deploy my-service --image gcr.io/my-project/my-image --timeout=300Sets the request timeout to 300 seconds (5 minutes) for the service, overriding the default 60-minute timeout.
Timeouts are configurable up to 60 minutes (managed) or 24 hours (Anthos); exam questions ask about the impact on long-running processes.
gcloud run services describe my-service --region us-central1 --format='json'Outputs the full configuration of a Cloud Run service in JSON format, useful for debugging and automation.
The describe command is essential for retrieving status and configuration details; exam scenarios may ask for the JSON output to find specific fields.
gcloud run revisions list --service my-service --region us-central1Lists all revisions for a specific service, showing their deployment timestamps, status, and traffic allocation.
Understanding revision versions and their lifecycle is tested; knowing this command helps answer revision management questions.
Cloud Run appears directly in 216exam-style practice questions in Courseiva's question bank — one of the most-tested concepts on Google ACE. Practise them →
Must Know for Exams
Cloud Run is a key concept in Google Cloud certification exams, especially the Associate Cloud Engineer (ACE), Professional Cloud Architect (PCA), and Cloud Digital Leader exams. It also appears in AWS and Azure exams in the context of comparing serverless container services to their own offerings like AWS Fargate, Azure Container Instances, and Azure Container Apps.
In the Google Cloud Associate Cloud Engineer exam, candidates should know how to deploy a container to Cloud Run using the console, gcloud command line, and Cloud Build. They need to understand the concept of revisions, traffic splitting, and how to set environment variables and secrets. Questions often present a scenario where a company wants to migrate a monolithic application to microservices with minimal operational overhead, and the correct answer is to use Cloud Run for each microservice.
For the Professional Cloud Architect exam, the focus expands to designing systems using Cloud Run. Candidates must evaluate when to use Cloud Run versus Compute Engine, GKE, or Cloud Functions. They need to consider factors like execution time limits (60 minutes for Cloud Run), request concurrency, cold start latency, and the use of min-instances for latency-sensitive applications. Questions may ask about hybrid use cases where Cloud Run processes synchronous API requests while Cloud Functions handles background event-driven tasks.
In AWS exams like AWS Developer Associate and AWS Solutions Architect, Cloud Run is not directly tested but the concept of serverless containers is relevant. AWS Fargate is the equivalent service. Candidates should know the differences: Cloud Run is fully serverless (no cluster management), while Fargate still requires you to define tasks and services within an ECS cluster, though it manages the underlying servers.
Azure exams like AZ-104 and Azure Fundamentals cover Azure Container Instances and Azure Container Apps. Azure Container Apps is the closest equivalent to Cloud Run. Exam questions in Azure may ask you to choose between ACI (good for simple tasks) and Container Apps (good for microservices with scaling, revisions, and ingress).
The Cloud Digital Leader exam focuses on business benefits. Questions may ask which Google Cloud service provides a fully managed serverless platform for containers and is ideal for reducing operational costs. The key phrases are fully managed, serverless, pay-per-request, and no infrastructure management.
Simple Meaning
Imagine you want to open a food stand that sells hot dogs. In the old way of doing things, you would buy a big truck, stock it with supplies, and park it on the street all day, every day, even if no customers show up. You would pay for the truck, the fuel, and the parking spot whether you sold one hot dog or a hundred. That is like running your own server or virtual machine always on, always costing money.
Cloud Run is like renting a tiny, magical kitchen that only turns on when someone orders a hot dog. When a customer walks up and says, I want a hot dog, the kitchen instantly appears, cooks the hot dog, hands it over, and then disappears. You only pay for the few seconds the kitchen was active. If a thousand customers show up at once, a thousand kitchens appear to handle them all. If no one comes, no kitchens exist and you pay nothing.
In technical terms, Cloud Run takes your application code, packages it into a container (like a box that holds everything your app needs to run), and then runs that container on Google's infrastructure. You do not have to set up any servers, worry about operating systems, or plan for traffic spikes. The service automatically adds more copies of your container when traffic increases and removes them when traffic drops. This approach is called serverless computing because the server parts are completely hidden from you.
Cloud Run is particularly good for web applications, APIs, and bots that may have unpredictable traffic. It supports any programming language or framework you can put into a container. You can also connect it to other Google services like Cloud SQL for databases or Cloud Storage for files, making it a flexible building block for modern cloud applications.
Full Technical Definition
Cloud Run is a fully managed serverless container runtime environment built on the open-source Knative project, which is part of the Kubernetes ecosystem. It abstracts away all infrastructure management, including provisioning, scaling, load balancing, and logging. Developers package their application into a standard Docker container image, push that image to a registry like Artifact Registry or Docker Hub, and then deploy it to Cloud Run with a single command or through the Google Cloud Console.
The service operates on a pay-per-request pricing model, charging only for CPU, memory, and network resources consumed during request processing plus a small monthly fee for idle containers that are kept warm. Each container instance has a defined CPU allocation (from 0.25 to 4 vCPUs) and memory allocation (128 MB to 32 GB). Cloud Run supports two execution environments: the first generation environment is based on gVisor, a sandboxed kernel that provides strong isolation, while the second generation environment uses a lightweight virtual machine with a microVM for each container, offering lower latency and higher throughput.
When a request arrives, Cloud Run routes it through a global HTTP load balancer or through an internal VPC endpoint. The request is then forwarded to a running container instance. If no instance is available, the system starts a new container instance from the deployed image. This cold start process typically takes under a second for small containers but can take longer for larger images or those with complex startup logic. To mitigate cold starts, Cloud Run offers a min-instances feature that keeps a configured number of instances always warm and ready.
Cloud Run supports automatic HTTPS termination, TLS certificates managed by Google, and custom domain mapping. It also integrates with Cloud CDN and Google Cloud Armor for content delivery and security. For traffic management, Cloud Run supports gradual rollouts, traffic splitting, and multiple revisions. Each deployment creates a new revision, and you can route traffic percentages to different revisions, enabling blue-green and canary deployments without downtime.
Under the hood, Cloud Run uses the Knative Serving API. Knative defines resources like Service, Configuration, Revision, and Route. The Cloud Run control plane manages these resources, while the data plane runs the actual containers on Google Compute Engine instances or on Borg, Google's internal cluster management system. Each container instance runs in an isolated sandbox or microVM with its own filesystem, network stack, and process space.
Cloud Run also supports advanced features like environment variables, secrets from Secret Manager, VPC connector for accessing private network resources, and execution environment variables. You can configure concurrency, meaning how many parallel requests a single container instance can handle. By default, it is set to 80, but you can adjust it. Higher concurrency reduces costs and cold starts but requires your application to be thread-safe.
For observability, Cloud Run is integrated with Cloud Monitoring, Cloud Logging, and Cloud Trace. Every request is automatically logged with latency, status code, and instance ID. You can set up alerts for error rates or high latency. The service also provides detailed metrics for container instance count, request count, and CPU/memory utilization.
Real-Life Example
Let us compare Cloud Run to a ride-sharing service like Uber or Lyft. Imagine you need to get to the airport. In the traditional computing model, you would buy your own car, pay for insurance, parking, maintenance, and gas, and keep it in your garage at all times. Even if you only drive it once a week, you are paying for all that fixed cost. That is like running a virtual machine 24/7, paying for CPU and memory even when nobody is using your application.
Now imagine instead you use a ride-sharing app. When you need a ride, you open the app, request a car, and within minutes a driver shows up. They take you to the airport, you pay for that specific trip, and then you are done. The driver does not sit in your driveway waiting for you. They go pick up other passengers. You share the driver's time and the car's cost with many other people.
Cloud Run works the same way. When a user sends a request to your web application, Cloud Run instantly finds or creates a container instance to handle it. That instance lives only as long as the request is being processed. Once the request finishes, the instance may be reused for another incoming request, or if no more requests come in, it is shut down after a timeout period. You are charged only for the milliseconds of CPU and memory time that your container actually used.
If suddenly hundreds of people want to use your app at the same time, Cloud Run automatically creates more container instances to handle the load. It is like Uber sending a fleet of cars when a big concert ends. The platform handles all the complexity of deciding how many containers are needed, where to run them, and how to balance the traffic among them.
This analogy also highlights the trade-offs. With your own car, you have complete control over every aspect. You know the car is there, you can modify it however you want, and you do not have to worry about someone else using it. With a ride-sharing service, you have less control, but you get convenience and lower cost. Similarly, Cloud Run limits some low-level control like direct server access or custom kernel modules, but gives you enormous operational simplicity.
Why This Term Matters
Cloud Run matters because it dramatically simplifies the deployment and operations of containerized applications. For IT professionals, this means less time spent on server maintenance, patching, capacity planning, and scaling configurations. Instead of managing a fleet of virtual machines or a Kubernetes cluster, you focus on writing code and packaging it into a container. Cloud Run handles the rest.
In real-world practice, organizations often have many small to medium-sized services that do not justify the overhead of a full Kubernetes cluster. These services might be internal APIs, webhooks, data processing scripts, or static websites. Running them on traditional VMs wastes money because the machines sit idle for long periods. Serverless functions like Cloud Functions can handle simple event-driven tasks but have limitations on execution time and memory. Cloud Run fills the gap by offering the flexibility of containers with the simplicity of serverless.
For a company that needs to deploy a customer-facing web application that experiences variable traffic, Cloud Run provides automatic scaling that matches the demand exactly. During a marketing campaign, the app can scale to hundreds of instances. At night, it scales down to zero, saving money. The operations team does not need to be on call just to add more servers during a traffic spike.
Cloud Run integrates with the CI/CD pipeline seamlessly. Developers can push code to a repository, have a build system like Cloud Build create a container image, and deploy it to Cloud Run automatically. This enables rapid iteration and continuous delivery. The service also supports revision-based rollbacks, so if a deployment introduces a bug, you can revert to the previous version with a single click or command.
How It Appears in Exam Questions
Cloud Run questions appear in several distinct patterns across Google Cloud exams.
Scenario-based pattern: A company runs a web application on a Compute Engine instance. The instance is often underutilized, and the team spends too much time patching and updating the OS. The company wants to reduce operational overhead and only pay for what they use. Which serverless option should they choose? The correct answer is Cloud Run because it can run containerized web applications with autoscaling and no server management.
Configuration pattern: A developer deploys a new revision to Cloud Run but wants to test it with 10% of traffic before rolling it out to all users. What feature should they use? Answer: Traffic splitting or gradual rollout. The question might ask for the correct gcloud command, like gcloud run services update-traffic, or ask about the console interface where you can set traffic percentages per revision.
Troubleshooting pattern: After deploying a container to Cloud Run, users report that the application is very slow on the first request after a period of inactivity. The candidate needs to identify that this is a cold start issue and suggest using the min-instances feature to keep one instance always warm. Alternatively, the question might ask about reducing container image size or optimizing startup code to reduce cold start latency.
Comparison pattern: What is the difference between Cloud Run and Cloud Functions? Answer: Cloud Run supports any containerized application with full control over the runtime, while Cloud Functions is limited to specific runtimes and has shorter execution timeouts and less memory. Cloud Run also supports concurrent requests on one instance.
Best practice pattern: The question asks about security best practices for Cloud Run. Options may include using Secret Manager for sensitive data, enabling HTTPS, using a VPC connector for private network access, and minimizing the permissions of the service account used by the deployment.
Practise Cloud Run Questions
Test your understanding with exam-style practice questions.
Example Scenario
A small e-commerce company sells handmade crafts online. They have a website that shows product listings, a shopping cart, and a checkout process. Currently, they run everything on a single virtual machine that they manage themselves. During the holiday season, traffic increases tenfold, and the website becomes slow or crashes. They want a solution that automatically handles traffic spikes and costs less during quiet months.
The company decides to migrate their cart and checkout services to Cloud Run. They already have their code containerized with Docker. The developer pushes the container image to Google Artifact Registry and then uses the command gcloud run deploy to launch it. They set the concurrency to 80 and memory to 512 MB.
During the holiday sale, thousands of customers visit the site simultaneously. Cloud Run automatically scales from one instance to over fifty instances in minutes. Each instance handles multiple requests concurrently. The website remains responsive. After the sale ends and traffic drops, Cloud Run scales down to zero instances, and the company stops paying for compute resources.
They also use Cloud Run's traffic splitting feature to slowly roll out a new version of the checkout process. They send 10% of traffic to the new revision for a day to monitor for errors, then 50%, then 100%. This gives them confidence that the update does not break the shopping experience.
Common Mistakes
Thinking Cloud Run runs on Kubernetes clusters you need to manage.
Cloud Run is serverless; Google manages the underlying infrastructure entirely. You do not see or manage any Kubernetes cluster, nodes, or pods.
Remember that Cloud Run is like a smart container runner that hides everything below the container level. You just give it a container image, and it runs it.
Believing Cloud Run supports long-running background processes like data processing that takes hours.
Cloud Run has a maximum request timeout of 60 minutes. For longer-running tasks, you should use Cloud Run jobs (for batch processing) or other services like Compute Engine or Dataflow.
Use Cloud Run for web requests and APIs that finish quickly. For long jobs, use Cloud Run jobs or Batch on GKE.
Expecting Cloud Run to be free because serverless often means free.
Cloud Run has a generous free tier, but beyond that, you pay for CPU, memory, requests, and networking. Cold starts also consume resources.
Review the Google Cloud pricing page for Cloud Run. Use the free tier for small projects, but budget for production workloads.
Thinking Cloud Run cannot access a private Cloud SQL database or on-premises resources.
Cloud Run can connect to private resources through VPC connectors or by using Serverless VPC Access. It can also use Cloud SQL Proxy for database connectivity.
Configure a VPC connector in the same region as your Cloud Run service. Then your container can reach internal IPs in your VPC.
Assuming that if you set concurrency to 1, you avoid threading issues and it is the best practice.
Setting concurrency to 1 means each container instance handles only one request at a time, increasing the number of instances needed and potentially raising costs and cold starts. Modern web frameworks handle concurrency well.
Keep default concurrency (80) unless your application is single-threaded or uses blocking libraries. Test your application with multiple concurrent requests.
Forgetting to set appropriate CPU and memory limits, causing out-of-memory errors or slow performance.
Each container has limited resources. If your application needs more memory than allocated, it will crash. If CPU is too low, requests will be slow.
Monitor your application's resource usage under load and adjust the CPU and memory settings accordingly. Use Cloud Monitoring to see actual usage per instance.
Exam Trap — Don't Get Fooled
{"trap":"A question asks: Which Google Cloud service should you use to run a containerized application that needs to handle streaming data for up to 30 minutes per request? Options include Cloud Run, Cloud Functions, Compute Engine, and BigQuery. Many learners choose Cloud Run because it handles containers with HTTP requests."
,"why_learners_choose_it":"Cloud Run is a serverless container service, and the question mentions containerized application and a duration of 30 minutes, which is within Cloud Run's 60-minute limit. Learners see container and time limit and think it fits.","how_to_avoid_it":"Read the question carefully.
Cloud Run is optimized for HTTP request-response patterns. The word streaming is a red flag. Cloud Run does not natively support streaming protocols like WebSockets in the first-generation environment and has limitations for streaming responses.
A better choice for streaming might be a Compute Engine instance with a lightweight server or a specialized service like Google Cloud Media CDN for video streaming. Always consider the workload type, not just the container capability."
Commonly Confused With
Cloud Functions runs a single piece of code (a function) triggered by events like HTTP requests, Cloud Storage changes, or Pub/Sub messages. Cloud Run runs a full container with any runtime and any framework. Cloud Functions has a shorter timeout (9 minutes in first gen, 60 minutes in second gen) and limited memory (up to 32 GB in second gen, but 8 GB in first gen). Cloud Run supports concurrent requests on one instance; Cloud Functions does not.
Use Cloud Functions to resize an image when it is uploaded to Cloud Storage. Use Cloud Run to run a complete web application with multiple endpoints like a Flask or Express app.
GKE gives you a full Kubernetes cluster where you manage nodes, pods, services, and ingress. You have complete control at the cost of operational overhead. Cloud Run is serverless; you do not manage any cluster or nodes. GKE is better for complex microservices with custom networking, stateful applications, and those needing specific Kubernetes features. Cloud Run is simpler and faster to deploy for stateless HTTP services.
Run a stateful database on GKE with persistent volumes. Run a public API that recommends products on Cloud Run.
Compute Engine gives you a virtual machine with full control over the OS, installed software, and network configuration. You pay for the VM even when idle. Cloud Run abstracts the VM completely and only charges when your container is processing requests. Compute Engine is needed for applications that require custom kernel modules, specific OS configurations, or persistent background processes.
Run a legacy Windows application on Compute Engine. Run a modern Node.js API on Cloud Run.
AWS Fargate is a serverless container engine for Amazon ECS and EKS. Like Cloud Run, it lets you run containers without managing servers. However, Fargate requires you to define a task definition and run it within an ECS cluster. Cloud Run is simpler to set up and does not require a cluster concept. Fargate charges for the entire time the task is running, not per request. Cloud Run can scale to zero and charges per request.
Run a long-running batch process on AWS Fargate since it runs continuously until stopped. Run a webhook that receives occasional POST requests on Cloud Run to save costs.
Azure Container Apps is the closest equivalent to Cloud Run in Azure. Both are serverless container services that support revisions, traffic splitting, and autoscaling. However, Container Apps is built on Kubernetes and allows access to the underlying cluster in some configurations, while Cloud Run is more fully abstracted. Container Apps supports Dapr for microservices patterns and has different pricing (per second of vCPU and memory).
Deploy a microservice that uses Dapr for pub/sub on Azure Container Apps. Deploy a simple stateless API on Cloud Run.
Step-by-Step Breakdown
Write your application code
You create a web application in any programming language that listens on HTTP requests. For example, a Python Flask app or a Node.js Express server. Your application should be stateless, meaning it does not rely on local filesystem for data that must persist across requests. Any required state should be stored in an external service like a database or object storage.
Package your application in a Docker container
You create a Dockerfile that defines how to build your container image. The container should include your code, the runtime (like Python or Node), and any dependencies. The container must listen on the port defined by the PORT environment variable (default 8080). This ensures Cloud Run can route traffic to your application.
Push the container image to a registry
You build the image locally and push it to a container registry like Google Artifact Registry. This stores your image in a secure, accessible location. Cloud Run will pull the image from this registry when it needs to start a new instance. You can also use Cloud Build to automate the build and push step.
Create a Cloud Run service
In the Google Cloud Console, you click Create Service, select the container image from the registry, and set service name, region, CPU and memory allocation, concurrency, and other settings. Alternatively, you use the gcloud run deploy command. Cloud Run creates a new service and an initial revision.
Configure the service settings
You set environment variables, connect a VPC connector if needed, configure secrets from Secret Manager, and adjust scaling parameters like max-instances and min-instances. You also set the authentication settings: allow unauthenticated invocations for public APIs or require authentication with IAM for private services.
Deploy and receive a URL
Once deployed, Cloud Run assigns a unique HTTPS URL to your service, like https://your-service-xxxxx-uc.a.run.app. You can assign a custom domain if you like. Your application is now live and accessible on the internet (or within your VPC).
Handle incoming requests with autoscaling
When a request comes in, Cloud Run directs it to a running container instance. If no instance is available, it starts a new one from the container image. As traffic increases, Cloud Run adds more instances. If traffic decreases, it scales down to zero. Each instance can handle multiple concurrent requests based on the concurrency setting.
Monitor and update
You monitor your service using Cloud Logging and Cloud Monitoring. You deploy new revisions by pushing a new container image and redeploying. You can set up traffic splitting to roll out new versions gradually. If something goes wrong, you can rollback to a previous revision instantly.
Practical Mini-Lesson
To use Cloud Run effectively in a professional environment, you need to understand a few critical concepts beyond the basic deployment steps.
First, cold starts are the greatest source of user-facing latency. When no instances are running and a request arrives, Cloud Run must pull the container image (if not cached) and start the container. This can take a few hundred milliseconds to several seconds. To reduce cold starts, optimize your container image size. Use slim base images, remove unnecessary files, and layer your Dockerfile so that dependencies (which change less frequently) are cached in earlier layers. For critical services, use the min-instances setting to keep one or more instances always warm. This incurs a small cost but eliminates cold start latency entirely.
Second, understand the request handling model. Each instance is a single process that listens on a port. Cloud Run forwards HTTP requests to that port. If you set concurrency to 80, the same instance can handle up to 80 requests simultaneously. Your application must be written to handle concurrency safely. If you use a framework like Flask with the default development server, it is single-threaded and will block on a request until it finishes. You need to use a production WSGI server like Gunicorn with multiple workers, or use an asynchronous framework like FastAPI or Node.js which is inherently concurrent.
Third, manage state appropriately. Cloud Run containers can have a local filesystem, but it is ephemeral. When the instance is terminated, all local data is lost. For persistent data, use a managed database like Cloud SQL, Cloud Firestore, or Cloud Storage. For session data, use a distributed session store like Redis (Memorystore) or Firestore.
Fourth, pay attention to networking. By default, Cloud Run services are public on the internet. To restrict access, use IAM roles and require authentication. For accessing private resources in your VPC, create a VPC connector that allows Cloud Run to send traffic to your VPC network. The connector must be in the same region as your Cloud Run service.
Fifth, configure health checks. Cloud Run automatically performs health checks on your container instance startup. You can also define startup and liveness probes to help Cloud Run determine when your container is ready to receive traffic and when it is unhealthy. This improves reliability during deployments and scaling events.
A common mistake professionals make is not setting appropriate CPU and memory limits. If your application uses more memory than allocated, the container is killed with an out-of-memory error. Monitor your application under realistic load and adjust these values. Similarly, if your application is CPU-bound, allocate more CPU to keep response times low.
Finally, implement proper logging and error handling. Cloud Run automatically captures logs from stdout and stderr. Use structured logging with JSON to make logs easier to query in Cloud Logging. Handle errors gracefully in your application so that the container does not crash unexpectedly. Use Cloud Monitoring alerts to notify you of high error rates or high latency.
Cloud Run Execution Environments and Cold Starts
Cloud Run is a fully managed compute platform that automatically scales stateless containers. Understanding its execution environment is critical for both performance optimization and cost control. Every Cloud Run service runs in a sandboxed container instance that is invoked only when a request arrives.
When no requests are present, the instance count can scale down to zero. This serverless characteristic introduces the concept of cold starts. A cold start occurs when a new container instance is initiated to handle an incoming request because no warm instance is available.
The time required for a cold start includes pulling the container image from the Container Registry or Artifact Registry, initializing the runtime, and starting your application code. Cold starts typically add 1 to 5 seconds to the first request latency, depending on the image size and the complexity of initialization. To mitigate cold start latency, Cloud Run offers the min-instance feature, which keeps a specified number of instances always warm.
Setting min instances to a value greater than zero ensures that at least that many instances are always running and ready to serve traffic, eliminating cold starts for those instances. However, enabling min instances incurs continuous billing for the minimum number of instances even when no requests are processed. This trade-off between latency and cost is a common topic in Google Cloud exams.
The execution environment also imposes a maximum request timeout of 60 minutes by default, but this can be adjusted up to 60 minutes with Cloud Run (fully managed) or 24 hours with Cloud Run for Anthos. Each container instance can handle multiple concurrent requests by default, controlled by the concurrency setting. The default concurrency is 80, but you can lower it to limit simultaneous processing or increase it up to 1000 if your application is designed to handle high concurrency.
Memory is allocated per container instance and ranges from 128 MB to 32 GB. CPU is always allocated while a request is being processed, but you can also request a minimum CPU boost to improve cold start performance. Understanding these details is essential for the Google Cloud Associate Cloud Engineer and Professional Cloud Architect exams.
Cloud Run IAM and Access Control
Cloud Run integrates tightly with Identity and Access Management (IAM) to secure both the control plane and the data plane. When deploying a Cloud Run service, you must grant appropriate IAM roles to principals such as users, service accounts, and groups. The key roles are roles/run.
admin, roles/run.developer, and roles/run.invoker. The Cloud Run Admin role provides full control over services and revisions, including deployment, deletion, and configuration changes.
The Cloud Run Developer role allows deployment and modification of existing services but does not permit deletion of services or managing IAM policies. The Cloud Run Invoker role grants the ability to invoke (call) the service endpoint, which is essential for public or authenticated access. For services that need to access other Google Cloud resources, such as Cloud Storage or Firestore, you must attach a service account to the Cloud Run revision.
This service account should have the minimum necessary IAM permissions to access those resources. By default, Cloud Run uses the Compute Engine default service account, but it is a security best practice to create a dedicated service account with limited scopes. The service account is specified at deployment time using the --service-account flag in the gcloud command or in the YAML configuration.
In exams, you may be asked to identify the correct IAM role to allow an external user to trigger a Cloud Run service without granting deployment permissions. The answer is roles/run.invoker.
Cloud Run supports IAM conditions, which allow you to enforce access based on attributes such as IP address or time of day. For example, you can restrict invocation to requests coming from a specific VPC network. Another important security feature is the ability to require authentication for incoming requests.
By default, new Cloud Run services are set to allow unauthenticated invocation only if you explicitly grant the allUsers principal the run.invoker role. If you fail to set that role, the service URL will return a 403 error.
This behavior is frequently tested in associate-level exams. Cloud Run also integrates with VPC Service Controls to prevent data exfiltration, and it supports private networking via Serverless VPC Access connectors. These connectors allow Cloud Run to reach resources in your VPC network using internal IP addresses.
Understanding these IAM and networking concepts is crucial for passing the Google Cloud Digital Leader and Professional Cloud Architect certifications.
Cloud Run Deployment Strategies and Revisions
Cloud Run uses a revision-based deployment model. Each time you update a service's configuration or deploy a new container image, Cloud Run creates a new revision. Revisions are immutable snapshots of the service at a specific point in time.
You can manage traffic routing among multiple revisions to implement progressive delivery strategies such as canary deployments, blue/green deployments, or rollbacks. The most common deployment strategy is a gradual rollout, where you send a small percentage of traffic to a new revision while the majority goes to the old revision. This is achieved by using the --traffic flag in the gcloud command or by updating the traffic block in the service YAML.
For example, you can set a new revision to receive 10% of traffic and the old revision to receive 90%, then slowly shift more traffic to the new revision until it reaches 100%. If the new revision shows errors, you can instantly roll back by shifting all traffic back to the previous revision. Cloud Run also supports a latest revision tag, which always points to the most recently deployed revision regardless of traffic settings.
This tag is useful for testing before shifting traffic. Another important concept is the service URL and revision-specific URLs. Each revision gets a unique URL that you can use for direct access, bypassing traffic routing rules.
This allows you to test a revision in isolation before sending any production traffic. In exam scenarios, you might be asked to design a deployment strategy that minimizes downtime and allows quick rollbacks. The recommended approach is to use a canary deployment with a small initial traffic share.
Cloud Run also integrates with Cloud Deploy for more advanced continuous delivery pipelines. You can set environment variables, secrets, and resource limits per revision, so you can safely test configuration changes without affecting the current serving revision. The revision lifecycle includes a status: active, deploying, or obsolete.
Cloud Run automatically scales the number of container instances based on traffic. You can also set a maximum number of instances to control costs and prevent runaway scaling. Deleting a service removes all its revisions.
Understanding revision management and traffic splitting is a core competency tested in the Google PCA and ACE exams.
Cloud Run Cost and Scaling
Cloud Run pricing is based on three main factors: CPU allocation, memory allocation, and the number of requests processed. You pay only for the resources consumed while a request is being handled, plus any idle charges if you use min instances. The pricing model is per-second billing with a minimum charge of 1 minute per request.
CPU is billed at a rate per vCPU-second, and memory is billed per GB-second. The exact rates depend on the region and whether you are using the default CPU allocation (only during request processing) or CPU always on. When CPU is only allocated during request processing, you pay only when your container is actively serving traffic, making it very cost-effective for bursty workloads.
However, for background tasks like data processing that need to run outside of request handling, you must enable CPU always on, which incurs charges for the entire time the container instance is alive, including idle time. This option is necessary when you use background threads or asynchronous operations that continue after the HTTP response is sent. Cloud Run also charges for network egress, but ingress from Google Cloud services within the same region is often free.
The scaling behavior of Cloud Run directly affects cost. By default, Cloud Run can scale up to 1000 container instances per region, but you can set a lower maximum instance count via the --max-instances flag. Each instance consumes resources as long as it is processing requests.
To control costs, you should estimate your traffic pattern and set an appropriate maximum instance limit. For exam questions, you may be asked to calculate the cost of a Cloud Run service given request volume, average request duration, memory, and CPU settings. Another cost consideration is the use of min instances.
While min instances reduce latency by eliminating cold starts, they also cause continuous billing because instances are always running. For example, setting min instances to 2 means you are billed for two instances 24/7, even if no requests arrive. Cloud Run also offers a free tier with 2 million requests per month and 360,000 vCPU-seconds, 240,000 GB-seconds, and 1 GB of egress per month.
This free tier is useful for low-traffic applications and is a common promotional feature in exam questions. Cloud Run supports a feature called concurrency which allows multiple requests to be processed simultaneously on one instance, improving cost efficiency. By increasing concurrency, you reduce the number of instances needed, thus lowering total cost.
However, increasing concurrency too much can degrade performance if your application is not designed for high concurrency. Balancing cost, performance, and scaling is a fundamental skill assessed in the Google Cloud Digital Leader and Professional Cloud Architect exams.
Troubleshooting Clues
Service returns 403 Forbidden on invocation
Symptom: When calling the Cloud Run service URL, the API returns HTTP 403 Forbidden, even though the service exists.
By default, Cloud Run services require authentication. If the service has not been granted the roles/run.invoker role to the allUsers principal (for public access) or the correct user/service account, requests will be denied with a 403. This is a common misconfiguration after deployment.
Exam clue: Exam questions often present a scenario where a developer can deploy but cannot access the endpoint; the fix is to add an IAM binding for run.invoker.
Cold start latency is too high
Symptom: Initial requests to the service take 3-5 seconds longer than subsequent requests, causing poor user experience.
This happens because the container instance is being created from scratch when a request arrives. The delay includes image pull, runtime initialization, and application startup. Setting min-instances to a value greater than zero eliminates this for those warm instances.
Exam clue: Exam questions ask for the best solution to reduce cold start latency: answer is enabling min-instances, but be aware of cost implications.
Container fails to start with 'Image pull error'
Symptom: Deployment fails or revision becomes unhealthy with errors like 'Failed to pull image' or 'Image not found'.
This occurs when the container image cannot be accessed from the specified repository. Common causes: the image does not exist, the repository is private and Cloud Run does not have permission, or the image URL is incorrect. Cloud Run uses the Compute Engine default service account to pull images unless a custom service account is specified.
Exam clue: Exam questions test that the service account assigned to Cloud Run must have 'storage.objectViewer' role on the container registry or Artifact Registry.
Service is not scaling up despite increased traffic
Symptom: After a traffic spike, the service remains on a few instances and requests start timing out or returning errors.
Cloud Run scales based on concurrency and CPU utilization. If the concurrency setting is low (e.g., 1) and the max-instances limit is set too low, scaling is capped. Also, if the container is slow to respond, the autoscaler might not be able to create new instances fast enough. Another possibility is that the service has hit its max-instances limit.
Exam clue: Exam scenarios test that max-instances is the ceiling and concurrency affects how many requests each instance can handle; lowering max-instances is used for cost control but can cause throttling.
Background tasks are stopped after response is sent
Symptom: After the HTTP response is returned to the client, background threads or asynchronous jobs are abruptly terminated.
By default, Cloud Run only allocates CPU while a request is being processed. Once the response is sent, the CPU is deallocated and any background work is frozen or killed. To keep CPU active, you must enable CPU always on in the service configuration.
Exam clue: This is a classic exam question: how to ensure background tasks complete. Answer: set CPU to always on in the revision or service configuration.
Service URL returns 404 Not Found
Symptom: The service URL is accessible but returns a 404 HTTP status code.
This typically indicates that the service exists but the URL path does not match any route in your application. Cloud Run forwards the entire request path to the container; if the container's web server does not have a handler for that path, it returns 404. Alternatively, the service might be using a revision-specific URL that does not exist.
Exam clue: Exam questions might present this as a misconfiguration of the application code, not the Cloud Run service itself. Debug by checking application logs.
Billing unexpectedly high despite low traffic
Symptom: The monthly bill shows significant charges for Cloud Run even though the service receives very few requests.
This can happen if min-instances is set to a high value, causing instances to run 24/7. If CPU is set to always on, billing accrues even when no requests are processed. Another cause is having a large number of revisions or concurrency set too low, forcing many instances to run.
Exam clue: Cost-related questions test the understanding of min-instances and CPU always on being the main drivers of baseline costs.
Memory Tip
Think of Cloud Run as a taxi for your container: it shows up when you need it, takes your request where it needs to go, and leaves when done. You only pay for the ride.
Learn This Topic Fully
This glossary page explains what Cloud Run means. For a complete lesson with labs and practice, see the topic guide.
Covered in These Exams
Current Exam Context
Current exam versions that test this topic — use these objectives when studying.
Related Glossary Terms
A 2-in-1 laptop is a portable computer that can switch between a traditional laptop form and a tablet form, usually by detaching or rotating the keyboard.
The 24-pin motherboard connector is the main power cable that connects the computer's power supply unit (PSU) to the motherboard, supplying electricity to the motherboard and its components.
Two-factor authentication (2FA) is a security method that requires two different types of proof before granting access to an account or system.
A 3D printer is a device that creates physical objects by depositing layers of material based on a digital model.
5G is the fifth generation of cellular network technology, designed to deliver faster speeds, lower latency, and support for many more connected devices than previous generations.
The 8-pin CPU connector is a power cable from the power supply that delivers dedicated electricity to the processor on a computer's motherboard.
802.1Q is the networking standard that allows multiple virtual LANs (VLANs) to share a single physical network link by tagging Ethernet frames with VLAN identification information.
802.1X is a network access control standard that authenticates devices before they are allowed to connect to a wired or wireless network.
Quick Knowledge Check
1.A developer deploys a new Cloud Run service but receives a 403 Forbidden error when trying to access the URL. What is the most likely cause?
2.Which of the following commands is used to route 20% of traffic to a new revision during a canary deployment?
3.A Cloud Run service is processing background tasks after the HTTP response is sent. The tasks are being cancelled prematurely. What is the best solution?
4.How does Cloud Run pricing primarily work?
5.A Cloud Run service experiences slow cold starts. Which configuration change would directly reduce cold start latency?
Frequently Asked Questions
Can I use Cloud Run to run a database?
No, Cloud Run is designed for stateless containers. Its filesystem is ephemeral, and databases need persistent storage. Use Cloud SQL, Firestore, or Memorystore for databases, and connect to them from Cloud Run.
What is the maximum memory I can allocate to a Cloud Run container?
The maximum memory is 32 GB for the second generation execution environment. The first generation environment supports up to 4 GB. Allocate based on your application's needs and monitor usage.
How do I handle large file uploads in Cloud Run?
Cloud Run has a default request size limit of 32 MB. For larger files, upload them directly to Cloud Storage using a signed URL, and pass the file reference to your Cloud Run service for processing.
Does Cloud Run support WebSockets?
Cloud Run supports WebSockets in the second generation execution environment. The first generation environment has limited WebSocket support and is not recommended for production. Check the environment version when deploying.
How can I set a custom domain for my Cloud Run service?
You can map a custom domain by verifying ownership in Google Search Console and then adding the domain mapping in the Cloud Run console or using the gcloud command. Cloud Run automatically provisions an SSL certificate for your domain.
What is the difference between Cloud Run and Cloud Run for Anthos?
Cloud Run is the fully managed version on Google Cloud infrastructure. Cloud Run for Anthos runs on your own GKE cluster, giving you more control over the underlying Kubernetes infrastructure and allowing it to run on-premises or on other clouds.
Can I stop my Cloud Run service from scaling to zero?
Yes, you can set the min-instances parameter to a value greater than 0. This keeps the specified number of instances always running and ready to serve requests, eliminating cold starts. You will be charged for these instances even when idle.
Is Cloud Run available in all Google Cloud regions?
Cloud Run is available in many but not all Google Cloud regions. You can deploy to regions like us-central1, europe-west1, and asia-east1. Check the Google Cloud locations documentation for a full list of supported regions.
Summary
Cloud Run is a fully managed serverless container runtime that allows developers to deploy containerized applications without managing any underlying infrastructure. It automatically scales your containers from zero to thousands of instances based on incoming traffic, and you only pay for the resources consumed while requests are being processed. This makes it an ideal platform for stateless web applications, APIs, and microservices that experience variable or unpredictable traffic patterns.
For IT certification learners, understanding Cloud Run is especially important for Google Cloud exams, where it appears in scenarios involving cost reduction, operational simplification, and modern application deployment. It is also useful as a comparison point when studying AWS Fargate or Azure Container Apps. Key concepts to master include cold starts, concurrency settings, revision management, traffic splitting, and VPC integration.
The main takeaway for exam preparation is to recognize when Cloud Run is the most appropriate solution versus other compute options like Compute Engine, GKE, or Cloud Functions. Cloud Run excels where you need full container flexibility with serverless convenience. Avoid common mistakes like assuming it supports long-running processes, forgetting to set min-instances for low-latency applications, and misunderstanding the concurrency model. With this knowledge, you will be well-prepared to answer Cloud Run questions correctly in your certification exams.