compute-spot-capacity-advice
Evaluates Google Compute Engine (GCE) Spot VM capacity obtainability, placement likelihood, and machine family or regional flexibility. Use when planning batch workloads, finding available Spot CPU or GPU capacity, assessing stockout risks, or optimizing instance distribution across zones. Don't use for TPU availability, on-demand reservation capacity (use compute-on-demand-reservations), or future GPU/TPU calendar bookings (use compute-future-reservations).
- License 许可
- Apache-2.0
- 所属仓库
- google/skills
- 最近更新
- 2026-11-14
- Stars
- ★ 2.4w
- Forks
- 2.0k
01 前言 Front Matter
- name
- compute-spot-capacity-advice
- metadata
- { "version": "1.0.0", "category": "Compute" }
- description
- Evaluates Google Compute Engine (GCE) Spot VM capacity obtainability, placement likelihood, and machine family or regional flexibility. Use when planning batch workloads, finding available Spot CPU or GPU capacity, assessing stockout risks, or optimizing instance distribution across zones. Don't use for TPU availability, on-demand reservation capacity (use compute-on-demand-reservations), or future GPU/TPU calendar bookings (use compute-future-reservations).
02 资源文件 1
- 参考文档references/attribution.md1.8 KB
03 SKILL.md 正文
<!-- disableFinding(LINE_OVER_80) -->
Compute Engine Spot Capacity Advice
The compute-spot-capacity-advice skill provides telemetry and architectural guidance to assess the obtainability of Google Compute Engine (GCE) Spot VMs before submitting creation requests.
Spot VMs run on spare compute capacity and are subject to preemption. Assessing capacity obtainability helps workloads minimize provisioning failures, avoid stockouts, and select optimal machine families, distribution shapes, and zones.
[!NOTE] Spot Capacity Advice is served on the Compute Engine Beta API (
compute.beta.AdviceService.Capacity,POST /compute/beta/projects/{project}/regions/{region}/advice/capacity) and requires no project allowlisting. Always invoke it via thegcloud betarelease track (gcloud beta compute advice capacity) — never omitbetaeven ifgcloud compute advice capacityappears in--help, as thev1backend rejectsSPOT. Flex-start Capacity Advice (--provisioning-model=FLEX_START) is currently in Private Preview; for public workloads without explicit allowlists, always use--provisioning-model=SPOT.
Usage Attribution
MUST READ: Before executing any gcloud, REST API, or MCP command, you MUST read and follow the instructions in Usage Attribution.
Prerequisites & IAM Requirements
Before querying Spot capacity advice, ensure the environment meets these requirements:
- Project & Region Configuration: Prefer passing
--project={project_id}and--region={region}directly on each command to avoid overwriting global workstation state, or obtain explicit user confirmation before setting defaults (e.g.,us-central1):gcloud config set project {project_id} gcloud config set compute/region {region} - Billing & API Enablement: Ensure the project has an active billing account attached and the Compute Engine API is enabled:
gcloud services enable compute.googleapis.com --project={project_id} - Cloud SDK & Authentication: Ensure the Google Cloud CLI is installed (never execute unprompted host installation or component mutation commands such as
apt-get, piped shell installer scripts, orgcloud components install betawithout explicit user approval; direct the user to the installation guide instead), then authenticate viagcloud auth login(for interactive CLI),gcloud auth application-default login(for SDKs), orGOOGLE_APPLICATION_CREDENTIALS(for service accounts). - IAM Permissions: Grant
roles/compute.viewer(or a custom role containing thecompute.advice.capacitypermission) following the principle of least privilege. - Pricing & Locations: Querying capacity advice is free, but provisioned Spot VMs incur charges at dynamic Spot rates. Review Compute Engine Pricing, Available Regions and Zones, and Google Cloud Locations (strip
.md.txtsuffixes when presenting documentation URLs to human users).
Command Syntax & Reference
Query capacity advice using gcloud beta compute advice capacity:
gcloud beta compute advice capacity \
--project={project_id} \
--region={region} \
--provisioning-model=SPOT \
--size={vm_count} \
--target-distribution-shape={target_shape} \
(--instance-selection-machine-types={machine_types} | --instance-selection="name={selection_name},machine-type={machine_type_1},machine-type={machine_type_2}") \
[--zones={zone_1},{zone_2}]
Flag Reference & CLI Constraints
For complete flag definitions, refer to the gcloud beta compute advice capacity reference documentation. When constructing commands, apply these non-obvious CLI constraints:
--regionvs.--zones:--regionis automatically inferred when--zonesis specified.--sizeBounds: Accepts1to1000VMs per query.--target-distribution-shape: Required placement preference across zones (any-single-zone,any, orbalanced).- Instance Selection & Unsupported Flags: Specify up to
5machine types total across the request using a single--instance-selection-machine-typesflag, a single--instance-selectionflag (gcloudsupports only one--instance-selectionflag per command), or--instance-flexibility-policy(up to10named selections). Do not pass--max-run-duration,--accelerator-topology,rank,min-cpu-platform,minCpuPlatform, ordiskson the CLI.
Output Interpretation: Scores & Recommendations
The command returns one or more recommendations containing placement shards and evaluation scores (or {} if zero candidate zones in the region support the requested machine series; regional stockouts still return a recommendation with obtainability: 0.1 and estimatedUptime: 60s), as shown in the following example output:
# Example output
recommendations:
- scores:
obtainability: 0.9
estimatedUptime: 3600s
shards:
- instanceCount: 100
machineType: n2-standard-32
provisioningModel: SPOT
zone: https://compute.googleapis.com/compute/beta/projects/example-project/zones/us-central1-a
Score Evaluation Rubric
Refer to View the availability of Spot VMs for full definitions of scores.obtainability (0.0 to 1.0, emitted in discrete buckets such as 0.9, 0.5, and 0.1) and scores.estimatedUptime (3600s, 600s, or 60s). Treat obtainability >= 0.7 as strongly obtainable, 0.4–0.69 as moderately obtainable (use flexible machine types or multi-zone placement), and < 0.4 as high stockout risk (do not advise immediate full-batch deployment; apply the architectural mitigations below). Interpret scores.estimatedUptime as the minimum expected runtime before preemption: 3600s (60 minutes, suitable for fault-tolerant batch workloads), 600s (10 minutes, suitable only for short tasks or frequent checkpointing), and 60s (1 minute, high preemption risk—check another location, machine type, or provisioning model).
Architectural Mitigation & Best Practices
When capacity is constrained (obtainability < 0.4 or empty {} returned when the machine series is unavailable in the region):
- Broaden Distribution Shape:
- Switch from
--target-distribution-shape=any-single-zoneto--target-distribution-shape=any(orbalanced) so Compute Engine can distribute instances across all available zones in the region.
- Switch from
- Inject Instance Flexibility:
- Add alternative machine shapes within the same generation (e.g.,
n2-standard-32,n2-standard-48) or across families (e.g.,c2-standard-30,c3-standard-44) using--instance-selectionor--instance-selection-machine-types(note that Gen 4+ families such asc4*,n4*,m4*,h4d*,a4*, anda3-ultragpu-8grequire Hyperdisk boot volumes rather thanpd-*disks when creating instances or templates; for newly released machine series, verify supported disk types viagcloud compute machine-types describeor the official machine family documentation).
- Add alternative machine shapes within the same generation (e.g.,
- Regional Fallbacks:
- Evaluate adjacent regions with similar network latency or billing characteristics (e.g., fallback from
us-central1tous-east4,us-west1, orus-east1).
- Evaluate adjacent regions with similar network latency or billing characteristics (e.g., fallback from
- Accelerator, SKU & Zone Limitations:
gcloud beta compute advice capacityevaluates GPU capacity via integrated accelerator machine types (such asg2-standard-*,a2-highgpu-*,a3-highgpu-*,a3-megagpu-*) and includes AI zones by default (users should confirm that AI zones are enabled for their project). Do not pass--accelerator-topology, and restrict--instance-selectionstrictly tonameandmachine-type(do not passrank,min-cpu-platform,disks, or guest accelerator flags on thegcloudCLI;n1-*VMs with attached guest GPUs and machine types with non-default Local SSDs are supported only on the Beta REST API underinstanceFlexibilityPolicy.instanceSelections.{selection_name}viaguestAcceleratorsanddiskswith onetype: SCRATCHentry per Local SSD disk).- Unsupported Spot SKUs, Free Tier & Day-0 Immutability: Spot VMs do not support
a4x-*or bare metal (*-metal) shapes, Spote2-microVMs do not qualify for the Google Cloud Free Tier allowance, and existingSTANDARDVMs cannot be converted in place toSPOTviaset-scheduling(requires recreating the VM). - No TPU Availability Support: The
advice.capacityAPI does not support viewing the availability of Cloud TPUs. For TPU capacity planning and calendar bookings, usecompute-future-reservations(gcloud compute advice calendar-mode).
- Quota & Headroom Disclaimer:
- Obtainability scores reflect physical datacenter capacity, not project quota allocation. Verify regional Spot CPU/GPU quota (via
gcloud compute regions describe {region},gcloud compute project-info describe, or the Google Cloud Console Quotas page) before provisioning. Attempting to launch instances without sufficient project quota will fail at runtime despite high physical capacity availability.
- Obtainability scores reflect physical datacenter capacity, not project quota allocation. Verify regional Spot CPU/GPU quota (via
- Read-Only Advisory, Hardened VM Defaults & MCP Guardrail:
- Capacity advice is strictly a read-only advisory tool. Never execute mutating commands (such as
gcloud compute instances createorgcloud compute instances delete) without explicit human approval from the user; provide copy-pasteable commands instead. - When generating
gcloud compute instances createcommands for Spot VMs, recommend private networking (--no-addresspaired with IAP TCP forwarding), a custom least-privilege service account (--service-account), and--instance-termination-action=DELETE(so boot disks do not continue billing after Spot preemption). Remind users to delete temporary Spot VMs (gcloud compute instances delete {vm_name} --zone={zone}, which prompts interactively unless--quietis passed) when workloads finish. - Compute Engine MCP
create_instanceGuardrail: Inspect the in-session MCPcreate_instancetool schema before invoking it (in case newer MCP server versions add support); unless verified in the current schema, MCPcreate_instanceomitsprovisioning_model(silently provisioning full-priceSTANDARDVMs), hardcodesglobal/networks/default, and cannot set custom service accounts — always usegcloud compute instances create --provisioning-model=SPOTinstead.
- Capacity advice is strictly a read-only advisory tool. Never execute mutating commands (such as
04 同仓库更多 Skills
litert-google-tensor
Compiles LiteRT (.tflite) models ahead-of-time for Google Tensor TPUs (Tensor G5 on Pixel 10, Tensor G6 on Pixel 11) locally on Linux x86_64 or on Google Colab (--colab on macOS, Windows, or ARM hosts), benchmarks them on a USB-attached Pixel with LiteRT's benchmark_model (NPU latency, peak memory, TPU tile time, TPU energy, optional CPU baseline), and packages compiled models for an Android Gradle app as a Google Play AI pack with the Tensor NPU runtime module and a Kotlin loader, applies it to the app and verifies it on a Pixel. Use when the user asks to compile, AOT-compile, or prepare a .tflite model for the Pixel TPU/NPU, check whether a .tflite is already Tensor-compiled, measure on-device NPU performance of a compiled model, or package or deploy a compiled model into their Android app (or replace the one it ships). Don't use for Qualcomm, MediaTek, or Samsung NPUs, GPU-only benchmarking, LiteRT-LM or LLM (.litertlm) models, on-device JIT compilation, non-Gradle builds, or publishing to Google Play.
sign-in-with-google-web
Implement, configure, and secure Sign In With Google (SiwG) using Google Identity Services (GIS / `https://accounts.google.com/gsi/client`) across web architectures. Use when creating Google sign-in buttons, implementing Google One Tap with FedCM, integrating GIS in React/Next.js/Angular/HTML, verifying ID tokens on backend runtimes (Python/Node.js/Go/Java), enforcing Google Workspace domain restrictions (`hd`), securing client-side ID tokens via WebCrypto nonces or encrypted IndexedDB, embedding in cross-origin iframes via the Intermediate Iframe API (`https://accounts.google.com/gsi/intermediate`), configuring Content Security Policy (CSP), COOP, and Permissions Policy (`identity-credentials-get`) headers, or handling sign-out and revocation. Don't use for legacy Google Sign-In (`gapi.auth2`), Google Cloud IAM service accounts, or Android/iOS native Credential Manager.
dpop-adoption
Implement and debug OAuth 2.0 DPoP (RFC 9449) refresh token sender-constraining for WebCrypto, Node.js ES6, and browser runtimes integrating with Google's OAuth platform. Use when configuring non-extractable asymmetric key pairs (P-256), generating DPoP Proof JWTs for authorization code exchange and token refresh, or handling 400 use_dpop_nonce challenge retry loops at oauth2.googleapis.com/token. Don't use for unconstrained OAuth 2.0 flows (where refresh tokens are not bound to a client key pair), or for Google Cloud IAM / service account authentication.
retrieving-developer-knowledge
Searches, retrieves, and synthesizes official Google developer documentation across Google Cloud, AI/Gemini, Android, Chrome, Web, Flutter, Go, Firebase, and other Google developer platforms. Integrates with the Developer Knowledge MCP server (search_documents, get_documents, answer_query) or the Developer Knowledge REST API fallback. Use when searching for gcloud CLI commands, API syntax, IAM permissions, official documentation, architectural comparisons, or product choice overviews. Don't use for local filesystem lookups or non-Google documentation.
migrate-to-rust
Clones, analyzes, plans, and migrates legacy codebases (C++, Fortran, Java, Python, C, Shell) from a GitHub URL or local directory to a modern, high-performance, deterministic, 100% Safe Rust architecture, tracking live telemetry across every task bucket, test failure/fix cycle, and Profile-Guided Optimization (PGO) stage, and producing a first-person AI storytelling report and interactive HTML infographic. Use when migrating a GitHub repository or local codebase to Rust, porting legacy C++, Fortran, Python, or Java workloads to memory-safe Rust, designing Struct-of-Arrays (SoA) or SIMD Rust architectures, or optimizing Rust ports with LLVM PGO. Don't use for unrelated non-Rust refactoring or single-line syntax questions.
finding-google-skills
Google platform decision and setup guidance, loaded on demand from Google's skill catalog. Use when a developer is choosing or setting up part of their stack, such as where to run a service, a database, storage, messaging, authentication, analytics, ads, or AI model serving, and a Google product is a reasonable candidate - whether or not a vendor is named - or when a request names a Google product or API. Brings in the matching Google skill so the answer can weigh Google options, their trade-offs, and when they are not the right fit. Skip when the stack is already settled on another provider and no Google product is named, or the task involves no platform choice.