Files
2nd/10_Wiki/Topic_Programming/Architecture/Serverless_Architecture.md
T
Antigravity Agent 9148c358d0 docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를
Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류.

- 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로
  자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거,
  동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거.
- 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming,
  Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business,
  Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로,
  나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는
  title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백).
  원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지.
- 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서.
- 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는
  지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지.
- Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경.
- 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
2026-07-05 00:33:48 +09:00

5.4 KiB

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-serverless-architecture Serverless Architecture 10_Wiki/Topics verified self
Serverless
FaaS
Functions-as-a-Service
서버리스
none A 0.9 applied
architecture
cloud
serverless
faas
2026-05-10 pending
language framework
typescript aws-lambda

Serverless Architecture

매 한 줄

"매 서버 관리 없이 매 코드 실행 — 매 event-driven, 매 auto-scale, 매 pay-per-use". AWS Lambda (2014)로 매 popularize. 2026년에는 매 Lambda + EventBridge + Step Functions, Cloudflare Workers, Vercel Functions, Deno Deploy가 매 생태계 정점. 매 cold-start 문제는 매 SnapStart, Workers V8 isolate로 매 거의 해소.

매 핵심

매 특성

  • 매 No server mgmt: 매 OS/patching 없음.
  • 매 Event-driven: HTTP, queue, stream, schedule.
  • 매 Auto-scale: 매 0 → 1000s, 매 즉시.
  • 매 Pay-per-use: 매 idle cost 거의 0.
  • 매 Stateless: 매 ephemeral execution.

매 trade-off

  • 매 Cold start: 매 ms ~ 수 sec (매 Workers isolate ~ 5ms).
  • 매 Vendor lock-in: 매 AWS-specific event shape.
  • 매 Long-running 부적합: 매 limit (Lambda 15min, Workers 30s CPU).
  • 매 Stateful 부적합: 매 외부 state 필수.

매 응용

  1. API backend (Lambda + API Gateway).
  2. Webhook handler (Workers).
  3. Stream processing (Lambda + Kinesis).
  4. Cron jobs (EventBridge schedule).
  5. AI inference edge (Workers AI, Vercel AI SDK).

💻 패턴

매 AWS Lambda (TS, SAM)

// handler.ts
import type { APIGatewayProxyHandlerV2 } from "aws-lambda";

export const handler: APIGatewayProxyHandlerV2 = async (event) => {
  const body = JSON.parse(event.body ?? "{}");
  return {
    statusCode: 200,
    body: JSON.stringify({ ok: true, echo: body }),
  };
};
# template.yaml (SAM)
Resources:
  Api:
    Type: AWS::Serverless::Function
    Properties:
      Handler: dist/handler.handler
      Runtime: nodejs22.x
      SnapStart: { ApplyOn: PublishedVersions }  # 매 cold-start ↓
      Events:
        Http: { Type: HttpApi, Properties: { Path: /echo, Method: POST } }

매 Cloudflare Workers

export default {
  async fetch(req: Request, env: Env): Promise<Response> {
    const { pathname } = new URL(req.url);
    if (pathname === "/ai") {
      const r = await env.AI.run("@cf/meta/llama-3.3-70b-instruct", {
        prompt: "Hello",
      });
      return Response.json(r);
    }
    return new Response("ok");
  },
};

매 Step Functions (orchestration)

{
  "StartAt": "Validate",
  "States": {
    "Validate": { "Type": "Task", "Resource": "arn:aws:lambda:...:Validate", "Next": "Charge" },
    "Charge":   { "Type": "Task", "Resource": "arn:aws:lambda:...:Charge",   "Next": "Notify" },
    "Notify":   { "Type": "Task", "Resource": "arn:aws:lambda:...:Notify",   "End": true }
  }
}

매 EventBridge schedule

Cron:
  Type: AWS::Events::Rule
  Properties:
    ScheduleExpression: "cron(0 * * * ? *)"  # 매 hourly
    Targets: [{ Arn: !GetAtt MyFn.Arn, Id: hourly }]

매 Vercel Edge Function (RSC)

// app/api/hello/route.ts
export const runtime = "edge";
export async function GET() {
  return Response.json({ region: process.env.VERCEL_REGION });
}

매 Cold-start mitigation

// 매 outside handler — 매 init reused across invocations
import postgres from "postgres";
const sql = postgres(process.env.DB_URL!, { max: 1 });

export const handler = async () => {
  const rows = await sql`SELECT NOW()`;
  return rows;
};

매 Bun + Lambda (2026 trend)

FROM public.ecr.aws/lambda/provided:al2023
COPY --from=oven/bun:1.2 /usr/local/bin/bun /usr/local/bin/bun
COPY . ${LAMBDA_TASK_ROOT}
CMD ["bun", "run", "handler.ts"]

매 결정 기준

상황 Approach
매 spiky / unpredictable load Serverless (auto-scale-to-zero).
매 steady high QPS EC2/Fargate cheaper.
매 long-running batch Step Functions / Fargate.
매 ultra-low latency global Workers / Vercel Edge.
매 stateful 매 외부 state (DynamoDB/Redis).

기본값: 매 API + webhook → Lambda or Workers. 매 latency 중요 → Workers.

🔗 Graph

🤖 LLM 활용

언제: 매 event-driven workload, 매 auto-scaling 필요, 매 ops cost ↓. 언제 X: 매 long-running compute, 매 strict latency p99, 매 vendor-neutral 강제.

안티패턴

  • 매 huge Lambda monolith: 매 cold-start ↑, 매 cost ↑.
  • 매 sync chained Lambdas: 매 cost double-billing — Step Functions 사용.
  • 매 connection pool 매 handler 안: 매 연결 폭발.
  • 매 secret 매 env에 매 plaintext: 매 Secrets Manager / KMS.
  • 매 cold-start 무시: 매 user-facing path는 매 SnapStart/provisioned.

🧪 검증 / 중복

  • Verified (AWS Lambda docs, Cloudflare Workers docs, Vercel docs).
  • 신뢰도 A.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — Lambda+SnapStart, Workers, Step Functions patterns