Skip to content

Commit 28934f5

Browse files
committed
chore(infra): tune api memory headroom and HPA scaling
Lower api heap cap to 80% of the container limit (688Mi) so V8 GCs earlier and RSS stays off the 860Mi limit, and raise the HPA memory target to 160% so CPU drives scaling instead of a flat memory baseline pinning replicas.
1 parent 1c05d70 commit 28934f5

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

.infra/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ const apiRequests: pulumi.Input<{ cpu: string; memory: string }> = {
219219
const apiLimits: pulumi.Input<{ memory: string }> = {
220220
memory: `${memory}Mi`,
221221
};
222+
const apiHeapMemory = Math.floor(memory * 0.8);
222223

223224
const wsMemory = 1600;
224225
const wsRequests: pulumi.Input<{ cpu: string; memory: string }> = {
@@ -410,14 +411,17 @@ if (isAdhocEnv) {
410411
} else {
411412
appsArgs = [
412413
{
413-
env: [nodeOptions(memory), ...jwtEnv],
414+
env: [
415+
{ name: 'NODE_OPTIONS', value: `--max-old-space-size=${apiHeapMemory}` },
416+
...jwtEnv,
417+
],
414418
minReplicas: 3,
415419
maxReplicas: 25,
416420
limits: apiLimits,
417421
requests: apiRequests,
418422
readinessProbe,
419423
livenessProbe,
420-
metric: { type: 'memory_cpu', cpu: 120, memory: 130 },
424+
metric: { type: 'memory_cpu', cpu: 120, memory: 160 },
421425
createService: true,
422426
enableCdn: true,
423427
disableLifecycle: true,

0 commit comments

Comments
 (0)