Gethyn Jones
04/12/2022, 11:37 AMRoss Coundon
04/12/2022, 11:40 AMGethyn Jones
04/12/2022, 11:42 AMFrank
RDS
construct?Gethyn Jones
04/12/2022, 2:34 PMFrank
Frank
RDS
construct, we recommend using Kysely to interact with the DB through data api. @thdxr shared some reasonings in this thread https://serverless-stack.slack.com/archives/C01JG3B20RY/p1649089211861559Gethyn Jones
04/12/2022, 2:44 PMGethyn Jones
04/12/2022, 2:44 PMFrank
Gethyn Jones
04/12/2022, 2:46 PMFrank
Gethyn Jones
04/12/2022, 2:51 PMFrank
Gethyn Jones
04/12/2022, 2:52 PMFrank
Gethyn Jones
04/12/2022, 2:54 PMFrank
Gethyn Jones
04/12/2022, 3:03 PMnodeModules
for the functionGethyn Jones
04/12/2022, 3:04 PMexternalModules
when using typeorm in a layerthdxr
04/12/2022, 3:06 PMGethyn Jones
04/12/2022, 3:08 PMunfortunately with serverless you do have to pick libraries well designed for it☝️ exactly this. I don't think Typeorm is a good choice for serverless
thdxr
04/12/2022, 3:16 PMRob Squires
04/12/2022, 8:10 PMRob Squires
04/12/2022, 8:11 PMRob Squires
04/12/2022, 8:11 PMRob Squires
04/12/2022, 8:11 PMthdxr
04/12/2022, 8:12 PMRob Squires
04/12/2022, 8:12 PMthdxr
04/12/2022, 8:12 PMRob Squires
04/12/2022, 8:12 PMRob Squires
04/12/2022, 8:12 PMthdxr
04/12/2022, 8:12 PMRob Squires
04/12/2022, 8:12 PMthdxr
04/12/2022, 8:12 PMthdxr
04/12/2022, 8:13 PMRob Squires
04/12/2022, 8:13 PMnode server.js
from my laptop it would be < 1secondRob Squires
04/12/2022, 8:14 PMRob Squires
04/12/2022, 8:15 PMrequire()
on a slow diskRob Squires
04/12/2022, 8:16 PM- load 18MB of stuff from S3
- read + parse 18MB of JS into memory
- start some sort of TCP connection ready to accept data
Rob Squires
04/12/2022, 8:17 PMRob Squires
04/12/2022, 8:17 PMRob Squires
04/12/2022, 8:18 PMRob Squires
04/12/2022, 8:22 PMRoss Coundon
04/12/2022, 8:24 PMRob Squires
04/12/2022, 8:26 PMRob Squires
04/12/2022, 9:25 PMexport async function handler(event: any) {
return {
statusCode: 200,
body: JSON.stringify(["hello"]),
};
}
18MB bundle
cold start times via ab:
50% 852
66% 852
75% 852
80% 861
90% 862
95% 862
98% 862
99% 862
100% 862
Rob Squires
04/12/2022, 9:25 PMrequire("typeorm");
export async function handler(event: any) {
return {
statusCode: 200,
body: JSON.stringify(["hello"]),
};
}
18MB bundle
cold start times via ab:
50% 997
66% 1046
75% 2283
80% 2297
90% 3398
95% 3398
98% 3398
99% 3398
100% 3398
thdxr
04/12/2022, 9:27 PMRob Squires
04/12/2022, 9:28 PMRob Squires
04/12/2022, 9:33 PMRob Squires
04/12/2022, 9:34 PMRob Squires
04/12/2022, 9:50 PMconsole.log("pre require");
require("typeorm");
console.log("post require");
export async function handler(event: any) {
console.log("handler");
return {
statusCode: 200,
body: JSON.stringify(["hello"]),
};
}
--
cold start:
Response time 2.83 s
logs:
2022-04-12T21:48:05.331Z undefined INFO pre require
2022-04-12T21:48:07.569Z undefined INFO post require
2022-04-12T21:48:07.587Z f1b67089-98fc-47a8-8a1d-b1e200fee327 INFO handler
Rob Squires
04/12/2022, 9:55 PMRob Squires
04/13/2022, 12:59 PMRob Squires
04/13/2022, 12:59 PM"pg"
"aws-sdk" << this is an external
"pino"
"zod"
"kysely"
Rob Squires
04/13/2022, 1:00 PM