考题解析 | 利用 Amazon DynamoDB 构建高并发量的网站服务


  题目

An ecommerce company wants to launch a one-deal-a-day website on AWS. Each day will feature exactly one product on sale for a period of 24 hours. The company wants to be able to handle millions of requests each hour with millisecond latency during peak hours.
Which solution will meet these requirements with the LEAST operational overhead?
A. Use Amazon S3 to host the full website in different S3 buckets. Add Amazon CloudFront distributions. Set the S3 buckets as origins for the distributions. Store the order data in Amazon S3.
B. Deploy the full website on Amazon EC2 instances that run in Auto Scaling groups across multiple Availability Zones. Add an Application Load Balancer (ALB) to distribute the website traffic. Add another ALB for the backend APIs. Store the data in Amazon RDS for MySQL.
C. Migrate the full application to run in containers. Host the containers on Amazon Elastic Kubernetes Service (Amazon EKS). Use the Kubernetes Cluster Autoscaler to increase and decrease the number of pods to process bursts in traffic. Store the data in Amazon RDS for MySQL.
D. Use an Amazon S3 bucket to host the website's static content. Deploy an Amazon CloudFront distribution. Set the S3 bucket as the origin. Use Amazon API Gateway and AWS Lambda functions for the backend APIs. Store the data in Amazon DynamoDB.

  参考答案

D

  参考解析

技巧:排除明显错误选项,在没有明显错误的选项中选择最合理的选项。
某电商公司希望在 AWS 上推出每日一单(one-deal-a-day)网站服务。其核心需求包括高并发处理能力、低延迟和最低运维开销。具体包括每小时需处理数百万请求,在高峰时段要求毫秒级响应,需要一种易于管理、自动化的解决方案,减少人工干预。

A. 不正确。使用 Amazon S3 + CloudFront,订单数据存储在 S3 存储桶。网站静态内容存储在 S3 存储桶,通过 CloudFront 全球分发,订单数据直接存储在 S3(如 JSON 文件)。问题是S3 是静态存储服务,无法处理后端动态逻辑(如用户认证、订单处理、库存更新等),也不是数据库,无法高效处理高频事务性写入(如订单提交)。另外动态请求(如获取库存状态)需回源到应用服务器,无法通过 CloudFront 缓存,会导致延迟增加。无法满足动态业务需求,运维开销虽低,但功能缺失严重。

B. 不正确。使用 EC2 Auto Scaling + ALB + RDS for MySQL 服务。网站部署在 EC2 实例上,通过 Auto Scaling 横向扩展,使用 ALB 分发流量,RDS for MySQL 存储数据。主要问题是,需管理 EC2 实例、操作系统、安全补丁等,运维开销高。Auto Scaling 需时间启动新实例,高峰时段可能无法立即响应,存在冷启动风险。RDS for MySQL 在高并发下可能成为性能瓶颈(如连接数限制、锁竞争),存在数据库瓶颈。虽能满足性能需求,但运维复杂度高,不符合最低运维开销要求。

C. 不正确。使用 Amazon EKS(Kubernetes) + RDS for MySQL 服务。应用容器化,部署在 EKS 上,通过 Kubernetes Cluster Autoscaler 扩展,使用 RDS for MySQL 存储数据。主要问题是,需管理 Kubernetes 集群、容器编排、网络策略等,运维开销极高;RDS for MySQL 在高并发下可能表现不佳,存在数据库瓶颈;Kubernetes 适合微服务架构,但单日一单场景无需复杂编排,不适合简单业务场景。

D. 正确。使用 S3 托管静态内容 + CloudFront + API Gateway + Lambda + DynamoDB 服务。网站前端(HTML/CSS/JS)存储在 S3 存储桶中,通过 CloudFront 分发。使用 API Gateway + Lambda 处理后端请求(如用户登录、订单提交)。使用 DynamoDB 存储订单和用户数据。该方案优势明显,采用 CloudFront 服务,为 S3 存储桶中的静态内容提供全球缓存,减少后端压力。API Gateway 提供 RESTful 接口,简化后端开发。Lambda 和 DynamoDB 无需手动配置容量,可自动处理高并发,也无需管理服务器、操作系统或数据库实例。Lambda 可以轻松实现毫秒级响应,无冷启动时(预置并发可优化),适合高频请求。DynamoDB 提供高吞吐量,单表设计可轻松支持每秒数万次写入。以上 AWS 服务都可以按需付费,无闲置资源浪费。