Skip to content

Commit 03c5a00

Browse files
authored
feat: increase webapp Lambda memory from 512MB to 1024MB (#116)
## Summary Increase the webapp Lambda function memory from 512MB to 1024MB to improve cold start performance. ## Problem With 512MB (0.29 vCPU), Next.js cold starts take over 20 seconds due to CPU-bound operations (JS bundle parsing, DNS resolution, TLS handshake). ## Measurement Results | Memory | vCPU | Cold Start P50 | Monthly Cost | vs 512MB | |--------|------|----------------|-------------|----------| | 512MB | 0.29 | 21.7s | $0.074 | — | | **1024MB** | **0.58** | **7.1s** | **$0.051** | **-32%** | | 1536MB | 0.87 | 5.6s | $0.060 | -19% | | 3008MB | 1.7 | 4.0s | $0.084 | +14% | 1024MB is the sweet spot: 3x faster cold starts and 32% cost reduction due to lower billed duration. ## Changes - `cdk/lib/constructs/webapp.ts`: memorySize 512 → 1024 - CDK test snapshots updated - README cost table updated Closes #101
1 parent 401f7ce commit 03c5a00

4 files changed

Lines changed: 4 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ The following table provides a sample cost breakdown for deploying this system i
130130
| Aurora Serverless v2 | 0.5 ACU × 2 hour/day, 1GB storage | 3.6 |
131131
| Cognito | 100 MAU (Monthly Active Users) | 1.5 |
132132
| AppSync Events | 100 events/month, 10 hours connection/user/month | 0.02 |
133-
| Lambda | 512MB×200ms/request | 0.15 |
133+
| Lambda | 1024MB×200ms/request | 0.15 |
134134
| Lambda@Edge | 128MB×50ms/request | 0.09 |
135135
| VPC | NAT Instance (t4g.nano) x1 | 3.02 |
136136
| EventBridge | Scheduler 100 jobs/month | 0.0001 |

cdk/lib/constructs/webapp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class Webapp extends Construct {
8282
ASYNC_JOB_HANDLER_ARN: asyncJob.handler.functionArn,
8383
},
8484
vpc: database.cluster.vpc,
85-
memorySize: 512,
85+
memorySize: 1024,
8686
architecture: Architecture.ARM_64,
8787
});
8888
handler.connections.allowToDefaultPort(database);

cdk/test/__snapshots__/serverless-fullstack-webapp-starter-kit-without-domain.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3466,7 +3466,7 @@ service iptables save",
34663466
},
34673467
},
34683468
},
3469-
"MemorySize": 512,
3469+
"MemorySize": 1024,
34703470
"PackageType": "Image",
34713471
"Role": {
34723472
"Fn::GetAtt": [

cdk/test/__snapshots__/serverless-fullstack-webapp-starter-kit.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3296,7 +3296,7 @@ service iptables save",
32963296
},
32973297
},
32983298
},
3299-
"MemorySize": 512,
3299+
"MemorySize": 1024,
33003300
"PackageType": "Image",
33013301
"Role": {
33023302
"Fn::GetAtt": [

0 commit comments

Comments
 (0)