Skip to main content

Amazon API Gateway

คืออะไร

Amazon API Gateway คือบริการ Fully Managed ที่ช่วยสร้าง, เผยแพร่, ดูแลรักษา, Monitor และรักษาความปลอดภัย API ในทุก Scale รองรับทั้ง REST API, HTTP API และ WebSocket API สามารถเชื่อมต่อกับ Lambda, EC2, ECS หรือ Backend Service อื่นๆ ได้ มีฟีเจอร์ด้าน Security เช่น API Key, IAM Auth, Cognito และ Custom Authorizer รวมถึง Rate Limiting และ Throttling

ราคา

  • REST API:
    • $3.50 ต่อ 1 ล้าน API Calls
    • Cache: $0.02-$3.84/ชั่วโมง ตามขนาด Cache
  • HTTP API (ถูกกว่า REST API ~70%):
    • $1.00 ต่อ 1 ล้าน API Calls (300 ล้าน calls แรก/เดือน)
  • WebSocket API:
    • $1.00 ต่อ 1 ล้าน Messages
    • $0.25 ต่อ 1 ล้าน Connection-minutes
  • Free Tier: 1 ล้าน REST API Calls/เดือน ฟรี 12 เดือน

เหมาะสำหรับ

  • สร้าง RESTful API สำหรับ Mobile และ Web Application
  • Serverless Backend ร่วมกับ Lambda
  • Microservices API Gateway
  • Real-time Application ด้วย WebSocket API

Use Case ตัวอย่าง

แอปพลิเคชัน Delivery ใช้ API Gateway เป็น Entry Point กลางสำหรับ API ทั้งหมด โดยกำหนด Rate Limit 100 requests/วินาที ต่อ API Key เพื่อป้องกัน Abuse ใช้ Cognito Authorizer ตรวจสอบ JWT Token ก่อนส่ง Request ไปยัง Lambda Function ที่รับผิดชอบแต่ละ Resource และ Cache Response ของ GET API ไว้ 5 นาที ลด Lambda Invocation ลงได้ 60%