Files
2nd/10_Wiki/Topics/Domain_Programming/Backend/Serverless_Computing.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

4.8 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-computing Serverless Computing 10_Wiki/Topics verified self
FaaS
Function-as-a-Service
Lambda
none A 0.9 applied
serverless
cloud
faas
backend
2026-05-10 pending
language framework
typescript aws-lambda/cloudflare-workers

Serverless Computing

매 한 줄

"매 server 관리 없이 event 단위로 코드를 실행". 매 2014 AWS Lambda 출시로 본격화. 매 2026 현재 Cloudflare Workers, Vercel Edge, AWS Lambda + Function URLs 의 edge-native serverless 가 mainstream — cold start 의 sub-10ms.

매 핵심

매 모델 비교

  • Container (ECS, Cloud Run): long-lived, scale-to-N. Cold start 100ms-2s.
  • Lambda (region): per-invocation, max 15min. Cold start 100-500ms.
  • Edge (Workers, Vercel): V8 isolate, sub-millisecond cold start, max 30s CPU.
  • Durable (Durable Objects, Lambda + DynamoDB): stateful + serverless.

매 trade-offs

  • 장점: pay-per-use, auto-scale, ops-free.
  • 단점: vendor lock-in, cold start, debugging 어려움, time/memory limit.

매 응용

  1. API endpoint (Hono on Workers).
  2. Event processing (S3 → Lambda → SNS).
  3. Cron job (EventBridge schedule).
  4. WebSocket (API Gateway + Lambda).
  5. ML inference (Lambda + container image, 10GB).

💻 패턴

AWS Lambda (TypeScript)

import { APIGatewayProxyHandler } from 'aws-lambda';

export const handler: APIGatewayProxyHandler = async (event) => {
  const body = JSON.parse(event.body ?? '{}');
  const result = await processOrder(body);
  return { statusCode: 200, body: JSON.stringify(result) };
};

Cloudflare Workers (Hono)

import { Hono } from 'hono';

const app = new Hono<{ Bindings: { DB: D1Database } }>();

app.get('/users/:id', async (c) => {
  const id = c.req.param('id');
  const user = await c.env.DB.prepare('SELECT * FROM users WHERE id = ?').bind(id).first();
  return c.json(user);
});

export default app;

Cold start mitigation (provisioned concurrency)

# serverless.yml
functions:
  api:
    handler: handler.api
    provisionedConcurrency: 5  # always-warm
    reservedConcurrency: 100   # max parallel

Idempotent handler

const seen = new Map<string, any>();
export const handler = async (event: { id: string; data: any }) => {
  if (seen.has(event.id)) return seen.get(event.id);
  const result = await process(event.data);
  seen.set(event.id, result);
  return result;
};
// Production: use DynamoDB or Redis for cross-invocation idempotency

Edge function (Vercel)

export const config = { runtime: 'edge' };

export default async function handler(req: Request) {
  const url = new URL(req.url);
  const cached = await caches.default.match(req);
  if (cached) return cached;
  const data = await fetch(`${process.env.UPSTREAM}${url.pathname}`);
  const resp = new Response(data.body, { headers: { 'cache-control': 'max-age=300' } });
  await caches.default.put(req, resp.clone());
  return resp;
}

Durable Object (stateful)

export class Counter {
  constructor(private state: DurableObjectState) {}
  async fetch(req: Request) {
    let count = (await this.state.storage.get<number>('n')) ?? 0;
    count++;
    await this.state.storage.put('n', count);
    return new Response(String(count));
  }
}

Event-driven (S3 → Lambda)

def handler(event, context):
    for record in event['Records']:
        bucket = record['s3']['bucket']['name']
        key = record['s3']['object']['key']
        process_image(bucket, key)

매 결정 기준

상황 Approach
Low traffic API Lambda or Workers
Global low-latency Cloudflare Workers / Vercel Edge
Long-running (>15min) Container (Cloud Run, Fargate)
Stateful realtime Durable Objects
Heavy ML inference Lambda container image or SageMaker

기본값: Cloudflare Workers + Hono + D1 — 2026 의 best-DX serverless.

🔗 Graph

🤖 LLM 활용

언제: handler boilerplate, IAM policy 생성, cold start 분석. 언제 X: cost optimization (cloud bill 의 actual 측정 필요).

안티패턴

  • Lambda monolith: 1 function 의 multi-route → cold start blast radius.
  • Sync chain: Lambda A calls Lambda B sync — double charge + timeout risk.
  • No timeout: default 3s 의 leak.
  • Heavy init: connection pool init at handler 매 invoke → 매번 cold.

🧪 검증 / 중복

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

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — Serverless 2026 state