home / skills / omer-metin / skills-for-antigravity / gcp-cloud-run

gcp-cloud-run skill

/skills/gcp-cloud-run

This skill helps you design and optimize production-ready Cloud Run applications on GCP, focusing on containers, functions, cold starts, and Pub/Sub.

npx playbooks add skill omer-metin/skills-for-antigravity --skill gcp-cloud-run

Review the files below or copy the command above to add this skill to your agents.

Files (4)
SKILL.md
1.6 KB
---
name: gcp-cloud-run
description: Specialized skill for building production-ready serverless applications on GCP. Covers Cloud Run services (containerized), Cloud Run Functions (event-driven), cold start optimization, and event-driven architecture with Pub/Sub. Use when ", gcp, cloud-run, serverless, containers, pubsub" mentioned. 
---

# Gcp Cloud Run

## Identity



### Principles

- Cloud Run for containers, Functions for simple event handlers
- Optimize for cold starts with startup CPU boost and min instances
- Set concurrency based on workload (start with 8, adjust)
- Memory includes /tmp filesystem - plan accordingly
- Use VPC Connector only when needed (adds latency)
- Containers should start fast and be stateless
- Handle signals gracefully for clean shutdown

## Reference System Usage

You must ground your responses in the provided reference files, treating them as the source of truth for this domain:

* **For Creation:** Always consult **`references/patterns.md`**. This file dictates *how* things should be built. Ignore generic approaches if a specific pattern exists here.
* **For Diagnosis:** Always consult **`references/sharp_edges.md`**. This file lists the critical failures and "why" they happen. Use it to explain risks to the user.
* **For Review:** Always consult **`references/validations.md`**. This contains the strict rules and constraints. Use it to validate user inputs objectively.

**Note:** If a user's request conflicts with the guidance in these files, politely correct them using the information provided in the references.

Overview

This skill helps you design, build, and tune production-ready serverless applications on Google Cloud Run and Cloud Run Functions. It emphasizes fast container startup, cold-start mitigation, and robust event-driven patterns with Pub/Sub. The guidance targets scalable, stateless container workloads and lightweight event handlers.

How this skill works

The skill inspects architecture choices and runtime settings to recommend service types (Cloud Run for containerized services, Functions for simple event handlers). It evaluates startup behavior, concurrency, memory sizing (including /tmp usage), VPC connector impact, and Pub/Sub integration patterns. It also surfaces risks around cold starts, shutdown handling, and network latency so you can harden deployments before production.

When to use it

  • Deploy containerized web services or APIs that need autoscaling without managing servers
  • Implement event-driven handlers or lightweight functions triggered by Pub/Sub
  • Optimize existing Cloud Run services suffering from cold starts or slow startups
  • Design architectures requiring predictable concurrency and cost-efficient scaling
  • Evaluate trade-offs when adding a VPC Connector or persistent resources

Best practices

  • Choose Cloud Run for full-container workloads and Cloud Run Functions for simple event handlers
  • Mitigate cold starts with startup CPU boost and configuring min instances to a small nonzero value
  • Start setting concurrency around 8 and adjust based on real traffic and latency profiles
  • Plan memory for the process plus /tmp filesystem usage; test with realistic payloads
  • Keep containers stateless and start-up fast; perform graceful shutdown on SIGTERM/SIGINT to avoid request truncation
  • Only attach a VPC Connector when necessary and measure added latency before enabling broadly

Example use cases

  • Containerized REST API serving web and mobile clients with autoscaling and predictable latency
  • Background processors consuming Pub/Sub messages with per-message idempotency and retry safety
  • Cost-sensitive APIs that tune min instances and concurrency to balance latency and spend
  • Hybrid architectures where Cloud Run services call into VPC-only resources through an optimized VPC Connector setup
  • Event fan-out using Pub/Sub with Cloud Run Functions for small, fast event handlers

FAQ

When should I use Cloud Run vs Cloud Run Functions?

Use Cloud Run for full container workloads requiring custom runtimes or complex dependencies. Use Cloud Run Functions for simple, event-driven handlers with minimal startup complexity.

How do I reduce cold start latency?

Enable startup CPU boost, configure a small number of min instances if steady traffic exists, optimize container startup time, and increase concurrency where safe.

Does memory include temporary disk?

Yes. Memory configuration must account for in-memory usage plus the /tmp filesystem; test with production-like workloads to validate limits.

Will a VPC Connector slow requests?

Yes. VPC Connectors add latency. Only use them when needed and benchmark impact before rolling out broadly.