API Gateway + Lambda(Node.js 22) 구조인데, cold start가 10~14초씩 나옵니다. 워밍업 후에는 50ms로 빠른데, 트래픽 낮을 때 새 컨테이너 띄우면 사용자가 체감할 수준으로 느려요.
핸들러는 이런 구조입니다.
// handler.ts
import { PrismaClient } from "@prisma/client";
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { S3Client } from "@aws-sdk/client-s3";
import Stripe from "stripe";
import OpenAI from "openai";
const prisma = new PrismaClient();
const s3 = new S3Client({});
const ddb = new DynamoDBClient({});
const stripe = new Stripe(process.env.STRIPE_KEY!);
const openai = new OpenAI({ apiKey: process.env.OPENAI_KEY! });
export const handler = async (event) => {
// ...
};
번들러는 esbuild, 최종 zip 사이즈는 15MB 정도. 메모리는 1024MB로 설정.
댓글 0