Skip to main content

Serverless Architecture Patterns

MyTodoList — Mobile App Backend

  • API GatewayLambdaDynamoDB
  • Cognito สำหรับ authentication
  • Cognito สร้าง temporary credentials สำหรับเข้าถึง S3 โดยตรง (restricted policy)
  • DAX สำหรับ DynamoDB read caching
  • API Gateway caching สำหรับ response caching

MyBlog.com — Serverless Website

Static Content

  • S3 + CloudFront พร้อม OAC (Origin Access Control)

Dynamic REST API

  • API GatewayLambdaDAXDynamoDB
  • DynamoDB Global Tables สำหรับ global data distribution

Features

  • DynamoDB Streams → Lambda → SES สำหรับ welcome emails
  • S3 triggers (SQS/SNS/Lambda) สำหรับ thumbnail generation

Microservices Architecture

Synchronous

  • API Gateway, Load Balancers

Asynchronous

  • SQS, Kinesis, SNS, Lambda triggers

ข้อดีของ Serverless สำหรับ Microservices

  • Auto-scaling per function
  • Pay-per-use
  • API cloning, Swagger/OpenAPI SDK generation

Software Updates Offloading

  • วาง CloudFront หน้า ALB+ASG ที่มีอยู่
  • Cache static files ที่ edge → ลดการ scaling ของ ASG
  • ไม่ต้องเปลี่ยน architecture เดิม