无服务器架构利用托管的事件驱动服务(Lambda、API Gateway、DynamoDB、S3、SQS等)来构建应用程序,无需管理服务器——AWS处理所有扩展和基础设施。理解如何设计无服务器系统及其权衡对现代云架构非常有价值。
典型的无服务器架构
A serverless web app/API often combines:
API GATEWAY → receives HTTP requests, routes to Lambda (the API entry point)
LAMBDA → functions handle the business logic (run on demand, auto-scale)
DYNAMODB → serverless NoSQL database (scales automatically)
S3 → static assets / file storage (host the frontend, store uploads)
COGNITO → managed authentication
SQS/SNS/EventBridge → async messaging and event-driven flows
CLOUDFRONT → CDN for the frontend
→ No servers to manage; everything scales automatically; pay per use.
无服务器设计原则
✓ EVENT-DRIVEN — components react to events (HTTP, queue messages, S3 events, schedules)
✓ Small, single-purpose FUNCTIONS (Lambda does one thing well)
✓ STATELESS functions — state lives in databases/storage (functions are ephemeral)
✓ Use MANAGED services for everything (database, auth, messaging) — no servers anywhere
✓ Decouple with queues/events for resilience and async processing
