From 7d015e3ab929230ccaa26168c824b11e9dab0a2a Mon Sep 17 00:00:00 2001 From: null Date: Wed, 8 Jul 2026 03:04:26 -0500 Subject: [PATCH] fix(functions): gcf_gen1 fractional CPU to fit the Cloud Run CPU quota MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Deploys kept failing container healthchecks with "Quota exceeded for total allowable CPU per project per region" even in small batches: v2 gives every instance a full vCPU (needed for concurrency 80), and ~35 services at 1 vCPU exceeds this new project's default Cloud Run CPU quota under any accounting. cpu:'gcf_gen1' restores the gen1 fractional tiers (256MiB → 1/6 vCPU) — a 6x smaller footprint, identical to how these functions ran on gen1. Concurrency must be 1 with cpu<1; costless at dev scale. At launch: raise the quota, drop these two options to restore full-vCPU concurrency. Co-Authored-By: Claude Opus 4.8 --- functions/dist/options.js | 10 +++++++++- functions/dist/options.js.map | 2 +- functions/src/options.ts | 10 +++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/functions/dist/options.js b/functions/dist/options.js index 7d989c3d..398cdf6a 100644 --- a/functions/dist/options.js +++ b/functions/dist/options.js @@ -17,10 +17,18 @@ const v2_1 = require("firebase-functions/v2"); * For production: request a Cloud Run CPU quota increase (console → IAM & Admin → Quotas) and * raise this. ~80 concurrent requests per instance means 5 instances still serves ~400 in flight. * + * cpu 'gcf_gen1' + concurrency 1: v2 defaults every instance to a FULL vCPU (required for the + * default concurrency of 80). On this project's default Cloud Run CPU quota that made deploys + * fail their container healthchecks ("Quota exceeded for total allowable CPU"). gcf_gen1 uses + * the gen1 fractional tiers (256MiB → 1/6 vCPU, 512MiB → 1/3) — a 6x smaller CPU footprint, + * which is exactly how these workloads ran on gen1 until now. Concurrency must be 1 when + * cpu < 1; at dev scale that costs nothing. AT LAUNCH: request the Cloud Run CPU quota + * increase, then delete these two lines to restore 1 vCPU + concurrency 80. + * * This module is imported FIRST in index.ts so these options are set before any v2 function is * defined. It has no effect on the one v1 holdout (onUserDelete), which keeps its own defaults. */ -(0, v2_1.setGlobalOptions)({ region: 'us-central1', maxInstances: 5 }); +(0, v2_1.setGlobalOptions)({ region: 'us-central1', maxInstances: 5, cpu: 'gcf_gen1', concurrency: 1 }); /** Region constant for any per-function override that ever needs to pin it explicitly. */ exports.REGION = 'us-central1'; //# sourceMappingURL=options.js.map \ No newline at end of file diff --git a/functions/dist/options.js.map b/functions/dist/options.js.map index c235291f..8af2ffa9 100644 --- a/functions/dist/options.js.map +++ b/functions/dist/options.js.map @@ -1 +1 @@ -{"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":";;;AAAA,8CAAwD;AAExD;;;;;;;;;;;;;;;;;GAiBG;AACH,IAAA,qBAAgB,EAAC,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,CAAA;AAE5D,0FAA0F;AAC7E,QAAA,MAAM,GAAG,aAAa,CAAA"} \ No newline at end of file +{"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":";;;AAAA,8CAAwD;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,IAAA,qBAAgB,EAAC,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,CAAA;AAE7F,0FAA0F;AAC7E,QAAA,MAAM,GAAG,aAAa,CAAA"} \ No newline at end of file diff --git a/functions/src/options.ts b/functions/src/options.ts index 21ed7053..45d58287 100644 --- a/functions/src/options.ts +++ b/functions/src/options.ts @@ -15,10 +15,18 @@ import { setGlobalOptions } from 'firebase-functions/v2' * For production: request a Cloud Run CPU quota increase (console → IAM & Admin → Quotas) and * raise this. ~80 concurrent requests per instance means 5 instances still serves ~400 in flight. * + * cpu 'gcf_gen1' + concurrency 1: v2 defaults every instance to a FULL vCPU (required for the + * default concurrency of 80). On this project's default Cloud Run CPU quota that made deploys + * fail their container healthchecks ("Quota exceeded for total allowable CPU"). gcf_gen1 uses + * the gen1 fractional tiers (256MiB → 1/6 vCPU, 512MiB → 1/3) — a 6x smaller CPU footprint, + * which is exactly how these workloads ran on gen1 until now. Concurrency must be 1 when + * cpu < 1; at dev scale that costs nothing. AT LAUNCH: request the Cloud Run CPU quota + * increase, then delete these two lines to restore 1 vCPU + concurrency 80. + * * This module is imported FIRST in index.ts so these options are set before any v2 function is * defined. It has no effect on the one v1 holdout (onUserDelete), which keeps its own defaults. */ -setGlobalOptions({ region: 'us-central1', maxInstances: 5 }) +setGlobalOptions({ region: 'us-central1', maxInstances: 5, cpu: 'gcf_gen1', concurrency: 1 }) /** Region constant for any per-function override that ever needs to pin it explicitly. */ export const REGION = 'us-central1'