What are Cloud Run functions?
Cloud Run functions is a serverless execution environment forbuilding and connecting cloud services. With Cloud Run functions, you writesingle-purpose functions that are attached to events emitted from yourcloud infrastructure and services. Your function is triggered when an eventbeing watched is fired. Your code executes in a fully managed environment in Cloud Run.There is no need to provision any infrastructure or worry about managing any servers.
You can write Cloud Run functions using a number ofsupported programming languages.You can take your function and run it in any standard runtime environment forone of the supported languages, which makes both portability and local testinga breeze.
Connect and extend cloud services
Cloud Run functions provides a connective layer of logic that lets you writecode to connect and extend cloud services. Listen and respond to a file uploadto Cloud Storage, a log change, or an incoming message on a Pub/Subtopic. Cloud Run functions augments existing cloud services and lets youaddress an increasing number of use cases with arbitrary programming logic.Cloud Run functions have access to service account credentials andare thus seamlessly authenticated with the majority of Google Cloud services,including Cloud Vision, as well as many others. In addition,Cloud Run functions are supported by numerousGoogle Cloud client libraries, whichfurther simplify these integrations.
Events and triggers
Cloud events are things that happen in your cloud environment. These might bethings like changes to data in a database, files added to a storage system, or anew virtual machine instance being created.
Events occur whether or not you choose to respond to them. You create a responseto an event with a trigger. A trigger is a declaration that you are interestedin a certain event or set of events. Binding a function to a trigger lets youcapture and act on events. For more information on creating triggers andassociating them with your functions, seeCloud Run functions triggers.
Serverless
Cloud Run functions removes the work of managing servers, configuringsoftware, updating frameworks, and patching operating systems. The software andinfrastructure are fully managed by Cloud Run so that you just add code.Furthermore, provisioning of resources happens automatically in response toevents. This means that a function can scale from a few invocations a day tomany millions of invocations without any work from you.
Configurable
Functions are built into containers and deployed as services on Cloud Run.This gives you complete access and control over the behavior of the function.Refer to Cloud Run documentation to explore options for configuring yourservice, such as:
- Multi-event trigger management on functions
- High-performance Direct VPC egress
- The ability to mount Cloud Storage volumes
- Google-managed language runtimes,with automatic security updates on base images
- Traffic splitting and revision control
- Managed Prometheus and Open Telemetry support with sidecar containers
Use cases
Asynchronous workloads (such as lightweight ETL) or cloud automations (such astriggering application builds) now no longer need their own server or adeveloper to manually manage them. You deploy a function bound to theevent you want and you're done.
The fine-grained, on-demand nature of Cloud Run functions also makes it aperfect candidate for lightweight APIs and webhooks. In addition, the automaticprovisioning of HTTP endpoints when you deploy an HTTP function means there isno complicated configuration required as there is with some other services. Seethe following table for additional common Cloud Run functions use cases:
Use case | Description |
---|---|
Data processing / ETL | Listen and respond to Cloud Storage events such as when a file is created, changed, or removed. Process images, perform video transcoding, validate and transform data, and invoke any service on the internet from your Cloud Run functions. |
Webhooks | Using an HTTP trigger, respond to events originating from 3rd party systems like GitHub, Slack, Stripe, or from anywhere that can send HTTP requests. |
Lightweight APIs | Compose applications from lightweight, loosely coupled bits of logic that are quick to build and that scale instantly. Your functions can be event-driven or invoked directly over HTTP/S. |
Mobile backend | Use Google's mobile platform for app developers, Firebase, and write your mobile backend in Cloud Run functions. Listen and respond to events from Firebase Analytics, Realtime Database, Authentication, and Storage. |
IoT | Imagine tens or hundreds of thousands of devices streaming data into Pub/Sub, thereby launching Cloud Run functions to process, transform and store data. Cloud Run functions lets you do it in a way that's completely serverless. |
What's next
- Learn about the Cloud Run functions execution environment.
- Learn best practices for designing, implementing, testing, and deploying Cloud Run functions.