@caelo-cms/provisioning 0.11.4 → 0.11.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,6 +37,11 @@ import {
37
37
  MCP_IAP_SERVICE_ACCOUNT_ID,
38
38
  runServiceAccountId,
39
39
  } from "../../dist/gcp-names.js";
40
+ import {
41
+ DEFAULT_GATEWAY_MAX_INSTANCES,
42
+ DEFAULT_MAX_CONNECTIONS,
43
+ stackPoolBudget,
44
+ } from "../../dist/pool-budget-stack.js";
40
45
  import {
41
46
  ADMIN_MEMORY_DEFAULT,
42
47
  adminEnvContract,
@@ -93,7 +98,21 @@ const adminMinInstances = Number.parseInt(cfg.get("adminMinInstances") ?? "0", 1
93
98
  const adminMemory = cfg.get("adminMemory") ?? ADMIN_MEMORY_DEFAULT;
94
99
  const adminMaxInstances = Number.parseInt(cfg.get("adminMaxInstances") ?? "5", 10);
95
100
  const gatewayMinInstances = Number.parseInt(cfg.get("gatewayMinInstances") ?? "0", 10);
96
- const maxConnections = Number.parseInt(cfg.get("maxConnections") ?? "100", 10);
101
+ // #1254 — part of the connection budget (stacks/gcp has the long comment).
102
+ const gatewayMaxInstances = Number.parseInt(
103
+ cfg.get("gatewayMaxInstances") ?? String(DEFAULT_GATEWAY_MAX_INSTANCES),
104
+ 10,
105
+ );
106
+ const maxConnections = Number.parseInt(
107
+ cfg.get("maxConnections") ?? String(DEFAULT_MAX_CONNECTIONS["gcp-firebase"]),
108
+ 10,
109
+ );
110
+ // #1254 — every service's pool sizes, from the server's max_connections.
111
+ const poolBudget = stackPoolBudget("gcp-firebase", {
112
+ maxConnections,
113
+ adminMaxInstances,
114
+ gatewayMaxInstances,
115
+ });
97
116
  const backupRetentionDays = Number.parseInt(cfg.get("backupRetentionDays") ?? "7", 10);
98
117
  const iapAllowlistRaw = cfg.get("iapAllowlist");
99
118
  const iapAllowlist =
@@ -655,7 +674,7 @@ const envContractInputs = {
655
674
  const gatewaySvc = cloudRunService({
656
675
  serviceName: "gateway",
657
676
  minInstances: gatewayMinInstances,
658
- maxInstances: 100,
677
+ maxInstances: gatewayMaxInstances,
659
678
  memory: "512Mi",
660
679
  // #806 — remote MCP: chat turns stream through the gateway for minutes
661
680
  // (stack-contract.ts GATEWAY_TIMEOUT_SECONDS). The Firebase Hosting
@@ -670,7 +689,11 @@ const gatewaySvc = cloudRunService({
670
689
  // request passes its rate limits, captcha and honeypot; staging requests
671
690
  // pass the staging access gate.
672
691
  ingress: "INGRESS_TRAFFIC_ALL",
673
- contractEnv: [...gatewayEnvContract(envContractInputs), ...remoteMcpEnv.gateway],
692
+ contractEnv: [
693
+ ...gatewayEnvContract(envContractInputs),
694
+ ...remoteMcpEnv.gateway,
695
+ ...poolBudget.env.gateway,
696
+ ],
674
697
  });
675
698
 
676
699
  const adminSvc = cloudRunService({
@@ -693,6 +716,7 @@ const adminSvc = cloudRunService({
693
716
  gatewayService: gatewaySvc.name,
694
717
  }),
695
718
  ...remoteMcpEnv.admin,
719
+ ...poolBudget.env.admin,
696
720
  ],
697
721
  mediaVolume: adminMediaVolumeTemplate(adminMediaVolume(project, env)),
698
722
  });
@@ -32,6 +32,10 @@ pulumi stack output bootstrapUrl
32
32
 
33
33
  Open that URL once Caddy has issued the cert (~30 s).
34
34
 
35
+ ## Connection budget
36
+
37
+ The generated Compose file starts Postgres with `max_connections=100` and sizes every pool from it (#1254, docs/dev/connection-budget.md): the admin gets a cms_admin pool of 77 and a cms_public pool of 4, the gateway a pool of 2, and static builds 2 per pool.
38
+
35
39
  ## Destroy
36
40
 
37
41
  ```bash