Files
2nd/10_Wiki/Topics/Domain_Programming/Architecture/Serverless_Architecture.md
T
Antigravity Agent c24165b8bc refactor(topics): 멀티 에이전트용 지식 재편 — _Common(공통 기본기) + Domain_* 구조
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게
[공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류.
문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인).

- Topic_Programming → Domain_Programming (내부 구조 보존)
- Topic_Graphic → Domain_Design
- Topic_Business → Domain_Product
- Topic_General → Domain_General
- _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning),
  Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing)
- 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서)
- 빈 폴더 정리 (memory/procedures)
- 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 11:05:56 +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