Cloud Run Jobs

Developers readily embraced Cloud Run because it enabled them to run containers serverless for workloads that included web services, APIs, event processing, and so on. For these types of workloads, cloud executions can be triggered via HTTP requests or events such as a file being added to cloud storage. These workloads run until the response has been returned to the client. However, some workloads such as database migrations are not suited for this because their containers need to run to completion and they do not serve requests. So how can you run the containers for these workloads serverless? – using Cloud Run Jobs.

What are Cloud Run Jobs?

Cloud Run Jobs is a Cloud Run extension built to make it easier to use it for unattended batch jobs right along your services. This extension adds to Google Cloud’s serverless stack and it is still serverless and runs containers just like Cloud Run. The difference is, that it works better for unattended batch jobs like the ones mentioned above.

Cloud Run Jobs enables you to benefit from its integration into the Google Cloud ecosystem. Plus, it is a fully managed service so you won’t have to deal with infrastructure provisioning. It also offers fine-grained controls over workload permissions and built-in security features. You will also get multiple data storage solutions including Cloud Storage, Firestore, Cloud SQL, etc.

What is all possible with Cloud Run Jobs?

Cloud Run Jobs can start up in as little as 10 seconds, which is much faster than what it takes to start up a VM to run these unattended batch jobs. In addition, a VM is inefficient because you have to set it up, configure it, and remember to take it down as soon as the container runs to completion. With this Cloud Run extension, you don’t have to worry about this because of its autoscaling feature. Once a container runs to completion, Cloud Run scales to zero until the next job starts. When it does, its extension will automatically avail instances to run the container to completion.

If you need jobs to complete quickly, you can split the jobs into multiple tasks, with each task handling a subset of your input, and run them in parallel. That being said, what is Cloud Run Jobs useful for?

  • Scheduled Scripts – such as database maintenance, generating nightly reports, and compliance audit scripts.

  • Background processing – for example, if you have an e-commerce store and customers have abandoned their carts, you can use Cloud Run Jobs to send email campaigns for these abandoned carts.

  • Batch data processing – especially the extraction phase of ETL.

Since these jobs do not serve requests, how can you get them to run? There are two ways to do this. You can manually trigger it to run from the Google Cloud Console or a command line. But if you want the jobs to run overnight or when you’re not necessarily at your desk, you can use the Cloud Scheduler or anything that can call the Cloud Run Admin API.

Previous
Previous

What holds you back from moving to the cloud?

Next
Next

Google BigLake