Ngân hàng đề — AWS Certified Developer Associate
Tìm thấy 1356 câu.
How should the developer write the DynamoDB query?
- A Add a local secondary index (LSI) during table creation. Query the LSI by using eventually consistent reads.
- B Add a local secondary index (LSI) during table creation. Query the LSI by using strongly consistent reads.
- C Add a global secondary index (GSI) during table creation. Query the GSI by using eventually consistent reads.
- D Add a global secondary index (GSI) during table creation. Query the GSI by using strongly consistent reads.
Xem giải thích
🧩 Phân tích nội dung câu hỏi
Câu hỏi tập trung vào Amazon DynamoDB, một dịch vụ cơ sở dữ liệu NoSQL serverless của AWS. Một lập trình viên đang phát triển ứng dụng lưu trữ dữ liệu trong bảng DynamoDB và muốn truy vấn (query) bảng theo partition key (PK) giống bảng chính nhưng sử dụng sort key (SK) khác so với SK gốc của bảng. Quan trọng nhất, họ cần dữ liệu mới nhất (latest data) bao gồm tất cả các hoạt động ghi gần đây (recent write operations), nghĩa là yêu cầu strongly consistent reads để đảm bảo tính nhất quán mạnh (không chấp nhận dữ liệu cũ do replication lag).
🔍 Vấn đề cốt lõi:
- Bảng DynamoDB gốc chỉ cho phép query theo PK + SK gốc.
- Để query theo PK giống nhưng SK khác → cần secondary index.
- LSI (Local Secondary Index): Chia sẻ PK với bảng chính, SK khác; chỉ tạo lúc tạo bảng; hỗ trợ strongly consistent reads.
- GSI (Global Secondary Index): PK và SK độc lập; có thể tạo sau; chỉ hỗ trợ eventually consistent reads (dữ liệu có thể lag 1-2 giây).
- Yêu cầu "latest data with recent writes" → loại trừ eventually consistent (có thể miss writes mới).
📘 Tài liệu tham khảo:
- AWS DynamoDB Developer Guide: Secondary Indexes (cập nhật 2024-2026, LSI hỗ trợ strong consistency; GSI chỉ eventually).
- Read Consistency.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Add a local secondary index (LSI) during table creation. Query the LSI by using strongly consistent reads.
🛠️ Lý do chi tiết:
- LSI phù hợp vì chia sẻ exact partition key với bảng chính, cho phép query theo PK giống + SK khác.
- Phải add during table creation (không thể thêm sau).
- Strongly consistent reads đảm bảo dữ liệu latest và phản ánh tất cả recent writes ngay lập tức (không lag như eventually consistent).
- Đây là giải pháp tối ưu cho yêu cầu, tuân thủ best practices DynamoDB (single-digit millisecond latency với consistency cao).
📋 Giải thích tất cả các phương án
Dưới đây là phân tích từng lựa chọn, giữ nguyên văn bản gốc bằng tiếng Anh. Mỗi phương án được đánh giá ✅ đúng hoặc ❌ sai, kèm lý do bằng tiếng Việt:
-
❌ Add a local secondary index (LSI) during table creation. Query the LSI by using eventually consistent reads.
🧩 Phương án này sai vì tuy LSI đúng loại index (chia sẻ PK, SK khác, tạo lúc table creation), nhưng eventually consistent reads có thể bỏ lỡ recent writes (lag ~1 giây). Không đáp ứng yêu cầu "latest data with all recent write operations". -
✅ Add a local secondary index (LSII) during table creation. Query the LSI by using strongly consistent reads.
🛠️ Phương án này đúng hoàn toàn như đã giải thích ở trên: LSI + strong consistency là cách duy nhất đảm bảo query PK + SK khác với dữ liệu mới nhất, không lag. -
❌ Add a global secondary index (GSI) during table creation. Query the GSI by using eventually consistent reads.
📉 Phương án sai vì GSI không chia sẻ PK với bảng chính (PK độc lập), nên không phù hợp query theo "partition key" giống bảng gốc + SK khác. Hơn nữa, GSI chỉ hỗ trợ eventually consistent (lag writes), và "during table creation" không bắt buộc (có thể add sau). -
❌ Add a global secondary index (GSI) during table creation. Query the GSI by using strongly consistent reads.
🚫 Phương án sai kép: GSI không hỗ trợ strongly consistent reads (chỉ eventually consistent theo thiết kế DynamoDB đến 2026). Ngoài ra, GSI dùng PK riêng, không match yêu cầu "partition key" giống bảng chính.
💡 Lời khuyên thực hành (Best Practices)
- 🧪 Test với AWS Console hoặc CDK/Terraform: Tạo table với LSI, query
ConsistentRead: true. - ⚠️ Chi phí: Strong reads tốn gấp đôi RCU so với eventually.
- 🔄 Alternative nếu cần GSI: Dùng DynamoDB Streams + Lambda cho real-time sync, nhưng phức tạp hơn cho "latest data".
How should the developer support the new access pattern in the MOST operationally efficient way?
- A Add a new local secondary index (LSI) to the DynamoDB table that specifies order_date as the partition key and order_id as the sort key. Write the new Lambda function to query the new LSI index.
- B Write the new Lambda function to scan the DynamoDB table. In the Lambda function, write a method to retrieve and combine results by order_date and order_id.
- C Add a new global secondary index (GSI) to the DynamoDB table that specifies order_date as the partition key and order_id as the sort key. Write the new Lambda function to query the new GSI index.
- D Enable DynamoDB Streams on the table. Choose the new and old images information to write to the DynamoDB stream. Write the new Lambda function to query the DynamoDB stream
Xem giải thích
🧩 Phân tích nội dung câu hỏi
Câu hỏi xoay quanh việc tối ưu hóa access pattern mới trong Amazon DynamoDB. Cụ thể:
- Ứng dụng lưu trữ đơn hàng (orders) vào bảng DynamoDB với:
- Partition key:
customer_id(phân vùng dữ liệu theo khách hàng). - Sort key:
order_id(sắp xếp theo ID đơn hàng trong cùng partition). - Attribute:
order_date(ngày đặt hàng).
- Partition key:
- Access pattern cũ: Truy vấn theo
customer_idvàorder_id. - Access pattern mới: Truy vấn theo
order_datevàorder_id(ví dụ: lấy tất cả đơn hàng theo ngày và ID). - Yêu cầu: Triển khai AWS Lambda function mới hỗ trợ access pattern này một cách operationally efficient nhất (hiệu quả vận hành cao, chi phí thấp, performance tốt, dễ scale).
Mục tiêu là chọn giải pháp tối ưu nhất mà không ảnh hưởng lớn đến thiết kế table hiện tại, tận dụng tính năng DynamoDB để query nhanh mà không scan toàn bộ dữ liệu. 📈
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Add a new global secondary index (GSI) to the DynamoDB table that specifies order_date as the partition key and order_id as the sort key. Write the new Lambda function to query the new GSI index.
Lý do:
🛠️ Global Secondary Index (GSI) cho phép tạo index với partition key và sort key hoàn toàn khác so với table chính (khác với LSI). Ở đây, GSI dùng order_date làm partition key (phân vùng theo ngày) và order_id làm sort key – khớp chính xác access pattern mới. Lambda chỉ cần query GSI là lấy dữ liệu nhanh, efficient (O(1) thời gian, chi phí theo RCU/WCU riêng).
- Operationally efficient: Không thay đổi table chính, tự động đồng bộ dữ liệu, scale độc lập, hỗ trợ up to 20 GSI/table (tính đến 2026).
- Cập nhật AWS 2026: GSI hỗ trợ on-demand capacity, sparse indexes, và adaptive capacity để tối ưu chi phí. Lambda query GSI đơn giản, không cần code phức tạp.
📘 Tài liệu tham khảo:
- AWS DynamoDB Developer Guide - Global Secondary Indexes
- DynamoDB Best Practices - Secondary Indexes (cập nhật 2025-2026).
🔍 Phân tích tất cả các phương án
Dưới đây là phân tích chi tiết từng lựa chọn, giữ nguyên văn bản gốc tiếng Anh. Tôi đánh dấu ✅ đúng hoặc ❌ sai, kèm giải thích bằng tiếng Việt rõ ràng:
-
Add a new local secondary index (LSI) to the DynamoDB table that specifies order_date as the partition key and order_id as the sort key. Write the new Lambda function to query the new LSI index.
❌ Sai: LSI bắt buộc phải dùng cùng partition key với table chính (customer_id), chỉ thay đổi sort key được. Không thể dùngorder_datelàm partition key mới → LSI không hỗ trợ access pattern này. Ngoài ra, LSI phải tạo lúc build table (không thêm sau), giới hạn 10 LSI/table, và chia sẻ throughput với table chính (dễ throttle). Không efficient! -
Write the new Lambda function to scan the DynamoDB table. In the Lambda function, write a method to retrieve and combine results by order_date and order_id.
❌ Sai: Scan quét toàn bộ table (không dùng key), rất không efficient: performance kém (RCU cao), chi phí lớn (đặc biệt table lớn), timeout Lambda dễ xảy ra, không scale. Chỉ dùng cho table nhỏ hoặc ad-hoc, không phải production access pattern. AWS khuyến cáo tránh scan! -
Add a new global secondary index (GSI) to the DynamoDB table that specifies order_date as the partition key and order_id as the sort key. Write the new Lambda function to query the new GSI index.
✅ Đúng: Như giải thích ở trên. Đây là giải pháp tối ưu nhất, hỗ trợ query nhanh theo pattern mới mà không ảnh hưởng table chính. Lambda code đơn giản:Query(GSI name, KeyCondition: order_date = :date AND order_id = :id). -
Enable DynamoDB Streams on the table. Choose the new and old images information to write to the DynamoDB stream. Write the new Lambda function to query the DynamoDB stream
❌ Sai: DynamoDB Streams dùng để capture changes real-time (insert/update/delete), trigger Lambda cho event-driven (như replication). Không phải để query historical data theoorder_datevàorder_id– streams không hỗ trợ query index, chỉ đọc sequential shards, không efficient cho access pattern này (miss dữ liệu cũ nếu không lưu trữ). Phức tạp và tốn kém hơn GSI!
🏆 Kết luận & Best Practice
Giải pháp GSI là MOST operationally efficient vì tận dụng native DynamoDB indexes, giảm code custom, tối ưu chi phí/performance. Nếu table lớn, dùng Provisioned/On-Demand capacity cho GSI riêng. Test với AWS Console hoặc CDK/Serverless Framework cho Lambda. 🚀
📘 Tham khảo thêm: AWS Well-Architected Framework - DynamoDB (2026 edition).
Each item in the ExamScores table is identified with student_id as the partition key and subject_name as the sort key. The web application needs to display the student _id for the top scores for each school subject. The developer needs to increase the speed of the queries to retrieve the student_id for the top scorer for each school subject.
Which solution will meet these requirements?
- A Create a local secondary index (LSI) with subject_name as the partition key and top_score as the sort key.
- B Create a local secondary index (LSI) with top_score as the partition key and student_id as the sort key.
- C Create a global secondary index (GSI) with subject_name as the partition key and top_score as the sort key.
- D Create a global secondary index (GSI) with subject_name as the partition key and student_id as the sort key.
Xem giải thích
🧩 Phân tích nội dung câu hỏi
Câu hỏi xoay quanh việc tối ưu hóa truy vấn trên bảng Amazon DynamoDB tên ExamScores, lưu trữ dữ liệu điểm thi của học sinh. Bảng có các thuộc tính chính: student_id (khóa phân vùng - partition key), subject_name (khóa sắp xếp - sort key), và top_score (điểm số cao nhất).
Mỗi item đại diện cho một lần thi của học sinh theo môn học cụ thể. Ứng dụng web cần hiển thị student_id của học sinh có điểm cao nhất (top scorer) cho từng môn học (school subject). Vấn đề là truy vấn hiện tại chậm, cần giải pháp tăng tốc độ truy vấn để lấy nhanh student_id của top scorer theo từng subject_name.
🛠️ Yêu cầu kỹ thuật: Sử dụng index để query hiệu quả theo subject_name (nhóm theo môn), sắp xếp giảm dần theo top_score, và lấy student_id của item đầu tiên (top 1). Table chính chỉ hỗ trợ query theo student_id trước, không phù hợp trực tiếp cho yêu cầu này.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Create a global secondary index (GSI) with subject_name as the partition key and top_score as the sort key.
Lý do:
- GSI cho phép thay đổi hoàn toàn partition key (PK) và sort key (SK), độc lập với table chính.
- Với subject_name làm PK: Query tất cả items của một môn học chỉ bằng một partition query.
- top_score làm SK: Cho phép sắp xếp giảm dần (ScanIndexForward=false) để lấy item đầu tiên có điểm cao nhất, sau đó project student_id.
- Điều này tăng tốc độ query đáng kể (O(1) cho partition + scan sort key nhỏ), phù hợp với workload đọc theo subject. GSI hỗ trợ cập nhật tự động (eventual consistency), và theo kiến thức AWS 2026, DynamoDB vẫn ưu tiên GSI cho multi-access patterns như thế này.
- Không cần provision capacity riêng nếu dùng On-Demand mode.
📋 Giải thích tất cả các phương án (đúng/sai)
Dưới đây là phân tích chi tiết từng lựa chọn, giữ nguyên văn bản gốc bằng tiếng Anh. Mỗi phương án được đánh giá dựa trên đặc tính LSI/GSI của DynamoDB (LSI: cùng PK với table, giới hạn 10/index/table; GSI: PK/SK độc lập, không giới hạn số lượng nhưng tốn chi phí hơn).
-
❌ [SAI] Create a local secondary index (LSI) with subject_name as the partition key and top_score as the sort key.
Lý do sai: LSI bắt buộc phải dùng cùng partition key (student_id) với table chính, không thể thay đổi thành subject_name. Nếu thử tạo, DynamoDB sẽ báo lỗi validation. LSI chỉ thay đổi SK và projected attributes, không hỗ trợ query cross-partition theo subject. -
❌ [SAI] Create a local secondary index (LSI) with top_score as the partition key and student_id as the sort key.
Lý do sai: Tương tự, LSI không cho phép thay đổi partition key thành top_score (vẫn phải là student_id). Hơn nữa, dùng top_score làm PK sẽ phân tán dữ liệu kém (nhiều partition cho score tương tự), và không nhóm theo subject_name, dẫn đến query chậm/full table scan. -
✅ [ĐÚNG] Create a global secondary index (GSI) with subject_name as the partition key and top_score as the sort key.
Lý do đúng: Như giải thích ở trên. GSI linh hoạt thay đổi PK/SK, query hiệu quả:QueryGSI(PK=subject_name, ScanIndexForward=false, Limit=1)để lấy top scorer ngay lập tức. Hỗ trợ sparse index nếu top_score null ở một số items. -
❌ [SAI] Create a global secondary index (GSI) with subject_name as the partition key and student_id as the sort key.
Lý do sai: Tuy GSI hợp lệ về cấu trúc (PK=subject_name), nhưng SK=student_id không sắp xếp theo top_score, nên không thể dễ dàng lấy "top scorer" (phải scan toàn bộ partition của subject và so sánh score thủ công - chậm và tốn RCU). Không đáp ứng yêu cầu tăng tốc query top score.
📘 Tài liệu tham khảo (AWS cập nhật 2026)
- AWS DynamoDB Developer Guide: Secondary indexes - Phân biệt LSI vs GSI, best practices cho query patterns.
- DynamoDB Best Practices: GSI for alternative sort keys - Sử dụng SK numeric như top_score cho top-N queries.
- Exam DOP-C02 Blueprint: Domain 2.2 - High-performing DynamoDB architectures (AWS Certified DevOps Engineer Professional 2026 syllabus).
✅ Giải pháp này đảm bảo scalability, cost-effective với On-Demand billing! 🛠️
Which solution will meet these requirements?
- A Store the video in the /tmp folder within the Lambda execution environment. Push a Lambda function URL to the customer.
- B Store the video in an Amazon Elastic File System (Amazon EFS) file system attached to the function. Generate a pre-signed URL for the video object and push the URL to the customer.
- C Store the video in Amazon S3. Generate a pre-signed URL for the video object and push the URL to the customer.
- D Store the video in an Amazon CloudFront distribution. Generate a pre-signed URL for the video object and push the URL to the customer.
Xem giải thích
🧩 Phân tích nội dung câu hỏi
Câu hỏi mô tả một ứng dụng sử dụng AWS Lambda để tạo video ngắn một cách bất đồng bộ (asynchronously) dựa trên yêu cầu từ khách hàng. Quá trình tạo video có thể mất lên đến 10 phút. Sau khi hoàn thành, hệ thống sẽ đẩy URL tải video vào web browser của khách hàng. Yêu cầu chính là khách hàng phải truy cập được video ít nhất 3 giờ sau khi tạo.
🛠️ Thách thức chính:
- Lambda chạy ephemeral (tạm thời), không lưu trữ persistent lâu dài.
- Cần lưu trữ video an toàn, scalable và chia sẻ URL tạm thời (pre-signed URL) với thời hạn phù hợp (≥3 giờ).
- Phải tích hợp mượt mà với Lambda và browser khách hàng, tránh phức tạp về mạng/VPC/chi phí.
- Kiến thức cập nhật đến 2026: AWS Lambda hỗ trợ runtime mới nhất (Node.js 20.x, Python 3.12), S3 pre-signed URLs hỗ trợ TTL lên đến 7 ngày cho GET objects (không thay đổi lớn từ 2023-2026), EFS/CloudFront có cải tiến nhưng không thay đổi core limitation.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Store the video in Amazon S3. Generate a pre-signed URL for the video object and push the URL to the customer.
Lý do:
- Amazon S3 là dịch vụ object storage persistent, scalable, chi phí thấp lý tưởng cho video (hỗ trợ upload từ Lambda qua SDK).
- Pre-signed URL cho phép truy cập tạm thời mà không cần IAM policy công khai, có thể set expiry lên đến 7 ngày (dễ dàng >3 giờ), an toàn với HTTPS.
- Lambda dễ dàng upload video vào S3 bucket (dùng boto3 hoặc AWS SDK), sau đó generate pre-signed URL và push qua WebSocket/API Gateway đến browser.
- Phù hợp nhất: Không cần VPC, low-latency global, tích hợp native với Lambda (execution role cho s3:PutObject, s3:GetObject).
📋 Giải thích chi tiết tất cả các phương án
Dưới đây là phân tích từng lựa chọn (giữ nguyên văn bản gốc tiếng Anh). Tôi đánh dấu ✅ cho đúng, ❌ cho sai, kèm lý do cụ thể dựa trên best practices AWS DevOps.
-
Store the video in the /tmp folder within the Lambda execution environment. Push a Lambda function URL to the customer.
❌ Sai: Thư mục/tmptrong Lambda chỉ là temporary storage (tối đa 10GB, reset khi function cold start hoặc container recycle sau ~14 phút idle). Video không persistent, khách hàng không truy cập được sau vài phút, vi phạm yêu cầu 3 giờ. Lambda Function URL chỉ invoke function, không phục vụ file trực tiếp. -
Store the video in an Amazon Elastic File System (Amazon EFS) file system attached to the function. Generate a pre-signed URL for the video object and push the URL to the customer.
❌ Sai: Amazon EFS là file system shared cho Lambda (cần VPC, Access Point), phù hợp concurrent access nhưng chi phí cao (provisioned throughput), latency cao hơn S3. EFS không hỗ trợ pre-signed URL native (nó là NFS, không phải object storage như S3). Khách hàng browser khó mount EFS trực tiếp, không scalable cho public download. -
Store the video in Amazon S3. Generate a pre-signed URL for the video object and push the URL to the customer.
✅ Đúng: Như đã giải thích ở trên. S3 + pre-signed URL là giải pháp chuẩn AWS cho temporary access (Well-Architected Framework: Reliability pillar). Lambda upload nhanh (multipart cho video lớn), URL expire chính xác sau 3+ giờ. -
Store the video in an Amazon CloudFront distribution. Generate a pre-signed URL for the video object and push the URL to the customer.
❌ Sai: CloudFront là CDN (cache/distribute từ origin như S3), không phải storage gốc – không thể "store" trực tiếp mà không có origin. Pre-signed URL cho CloudFront cần signed cookies/URLs phức tạp (policy JSON), config OAI/OAC, kém hiệu quả hơn S3 đơn giản. Không meet yêu cầu storage primary.
📘 Tài liệu tham khảo
- AWS Documentation (2026 updates):
- Lambda Execution Environment (/tmp limitations).
- S3 Pre-signed URLs (max 7 ngày).
- Lambda with EFS (VPC required).
- CloudFront Signed URLs.
- AWS Well-Architected Framework: Storage & Database lens (S3 cho unstructured data như video).
- Exam Topic DOP-C02: Lambda integrations, Serverless storage (S3 preferred).
🛠️ Khuyến nghị DevOps: Sử dụng S3 Event Notifications + SQS cho async workflow nếu scale lớn. Test với AWS SAM CLI để verify pre-signed expiry!
The developer wants the Lambda function to process only the messages that pertain to email address changes. Additional subscribers to the SNS topic will process any other messages.
Which solution will meet these requirements in the LEAST development effort?
- A Use Lambda event filtering to allow only messages that are related to email address changes to invoke the Lambda function.
- B Use an SNS filter policy on the Lambda function subscription to allow only messages that are related to email address changes to invoke the Lambda function.
-
C
Subscribe an Amazon Simple Queue Service (Amazon SQS) queue to the SNS topic. Configure the SQS queue with a filter policy to allow only messages that are related to email address changes.
Connect the SQS queue to the Lambda function. - D Configure the Lambda code to check the received message. If the message is not related to an email address change, configure the Lambda function to publish the message back to the SNS topic for the other subscribers to process.
Xem giải thích
🧩 Phân tích chi tiết nội dung câu hỏi
Câu hỏi xoay quanh một lập trình viên đang phát triển AWS Lambda function được kích hoạt bởi các thông điệp từ Amazon SNS topic. Các thông điệp này đại diện cho cập nhật dữ liệu khách hàng từ hệ thống CRM (Customer Relationship Management).
Yêu cầu cụ thể:
- Lambda chỉ xử lý thông điệp liên quan đến thay đổi địa chỉ email (email address changes).
- Các subscriber khác của SNS topic sẽ xử lý các thông điệp còn lại.
Mục tiêu: Tìm giải pháp với ÍT NHIỆU CÔNG SỨC PHÁT TRIỂN NHẤT (LEAST development effort), nghĩa là ưu tiên cách tiếp cận không yêu cầu code tùy chỉnh, tận dụng tính năng native của AWS để filter thông điệp ngay từ nguồn, giảm thiểu độ phức tạp và chi phí vận hành.
📘 Kiến thức nền tảng (cập nhật đến 2026): SNS hỗ trợ filter policies trên subscription từ năm 2019, cho phép filter dựa trên message attributes (key-value pairs) mà không cần code. Lambda nhận SNS events qua subscription trực tiếp (push model), không dùng event source mapping như SQS. Điều này làm cho SNS filter policy là lựa chọn tối ưu nhất về effort.
✅ Đáp án đúng: Use an SNS filter policy on the Lambda function subscription to allow only messages that are related to email address changes to invoke the Lambda function.
Lý do lựa chọn 🛠️:
- Đây là giải pháp native của SNS, áp dụng trực tiếp trên subscription của Lambda đến SNS topic.
- Filter policy sử dụng JSON policy để kiểm tra message attributes (ví dụ:
{"type": ["email_change"]}), chỉ gửi thông điệp khớp đến Lambda, các thông điệp khác tự động loại bỏ mà không invoke Lambda. - LEAST effort: Không cần code, không thêm dịch vụ trung gian, setup qua AWS Console/CLI/SDK chỉ vài dòng. Giảm chi phí invoke Lambda không cần thiết và dễ scale.
- Hoàn hảo cho multi-subscriber: Các subscriber khác vẫn nhận full messages.
📋 Phân tích tất cả các phương án (với emoji đánh dấu đúng/sai)
-
❌ [SAI] Use Lambda event filtering to allow only messages that are related to email address changes to invoke the Lambda function.
Giải thích: Lambda event filtering (hay Input Filtering) chỉ áp dụng cho event source mappings (pull model) như SQS, DynamoDB Streams, Kinesis – KHÔNG hỗ trợ trực tiếp cho SNS subscriptions (push model). SNS-Lambda dùng subscription thuần, không có event source mapping. Sử dụng cách này yêu cầu refactor kiến trúc (ví dụ: qua SQS), tăng effort. Không phải giải pháp native cho SNS. -
✅ [ĐÚNG] Use an SNS filter policy on the Lambda function subscription to allow only messages that are related to email address changes to invoke the Lambda function.
Giải thích: Như đã nêu ở đáp án đúng. Filter policy hoạt động ở tầng SNS, dựa trên attributes/body patterns (hỗ trợ numeric/string/exists/exists-anywhere). Ví dụ policy:{"emailChange": [{"exists": true}]}. Zero code, instant setup, phù hợp multi-subscriber. Đây là best practice AWS khuyến nghị cho filtering SNS. -
❌ [SAI] Subscribe an Amazon Simple Queue Service (Amazon SQS) queue to the SNS topic. Configure the SQS queue with a filter policy to allow only messages that are related to email address changes. Connect the SQS queue to the Lambda function.
Giải thích: Thêm SQS làm trung gian với filter policy trên SQS subscription (tương tự SNS). Sau đó trigger Lambda từ SQS (cần event source mapping). Tăng effort cao: Thêm dịch vụ, config polling, quản lý dead-letter queue, chi phí cao hơn (SQS requests). Không "least effort" vì phức tạp hóa kiến trúc không cần thiết khi SNS filter đã đủ. -
❌ [SAI] Configure the Lambda code to check the received message. If the message is not related to an email address change, configure the Lambda function to publish the message back to the SNS topic for the other subscribers to process.
Giải thích: Yêu cầu code tùy chỉnh trong Lambda (parse message, if-else check attributes/body, republish via SNS SDK). Effort cao nhất: Phát triển/test code, xử lý loop infinite (nếu republish sai), tăng chi phí invoke Lambda cho mọi message (kể cả không khớp), vi phạm nguyên tắc serverless (stateless). Không scalable và dễ lỗi.
📚 Tài liệu tham khảo (AWS Docs cập nhật 2026)
- SNS Subscription Filter Policies: docs.aws.amazon.com/sns/latest/dg/sns-subscription-filter-policies.html – Chi tiết examples.
- Lambda với SNS: docs.aws.amazon.com/lambda/latest/dg/with-sns.html – Xác nhận không dùng event filtering.
- Lambda Event Source Filters: docs.aws.amazon.com/lambda/latest/dg/invocation-eventsourcemapping.html#invocation-eventsourcemapping-filters – Chỉ cho pull sources.
- AWS Well-Architected Framework (Serverless): Khuyến nghị filter sớm để giảm invoke (Reliability pillar).
Hy vọng phân tích này giúp bạn ôn thi DOP-C02 hiệu quả! 🚀 Nếu cần ví dụ code policy cụ thể, hỏi thêm nhé!
How can the developer ensure that no sessions are lost if an Amazon EC2 instance fails?
- A Use sticky sessions with an Elastic Load Balancer target group.
- B Use Amazon SQS to save session data.
- C Use Amazon DynamoDB to perform scalable session handling.
- D Use Elastic Load Balancer connection draining to stop sending requests to failing instances.
Xem giải thích
🧩 Phân tích chi tiết nội dung câu hỏi
Câu hỏi tập trung vào việc thiết kế một môi trường chịu lỗi (fault-tolerant) trên AWS, nơi dữ liệu phiên (client sessions) của người dùng cần được lưu trữ an toàn. Vấn đề chính là đảm bảo không mất bất kỳ session nào nếu một instance Amazon EC2 bị lỗi (fails).
📝 Bối cảnh: Trong ứng dụng web phân tán với nhiều EC2 instances sau Elastic Load Balancer (ELB), session thường được lưu cục bộ trên instance (stateful). Nếu instance fail, session cục bộ sẽ mất, dẫn đến trải nghiệm người dùng kém (ví dụ: phải login lại). Giải pháp cần lưu session ở nơi scalable, persistent và có độ trễ thấp, hỗ trợ fault-tolerance mà không phụ thuộc vào instance cụ thể. Đây là chủ đề phổ biến trong AWS Well-Architected Framework (Reliability Pillar), nhấn mạnh stateless architecture với external session stores.
🛠️ Yêu cầu cốt lõi: Giải pháp phải lưu session ngoài EC2 (off-instance), tự động replicate dữ liệu, và scale theo nhu cầu – phù hợp với kiến thức cập nhật AWS đến 2026 (DynamoDB Global Tables, DAX cho caching session).
✅ Đáp án đúng: Use Amazon DynamoDB to perform scalable session handling
Lý do lựa chọn:
- DynamoDB là dịch vụ NoSQL database serverless, fully managed, được thiết kế cho session management với scalability tự động, low-latency reads/writes (sub-millisecond với DAX), và fault-tolerance cao (multi-AZ replication, global tables).
- Session data được lưu trung tâm hóa, không phụ thuộc instance, nên nếu EC2 fail, session vẫn accessible từ instances khác qua ELB.
- AWS khuyến nghị chính thức cho stateless applications (xem AWS docs: "DynamoDB for Web Session Management").
- Hỗ trợ TTL (Time-to-Live) cho session expiry, và encryption at rest/transit cho bảo mật.
📘 Tài liệu tham khảo:
- AWS Documentation: Using DynamoDB for Session Management (cập nhật 2024-2026 với DAX v2).
- AWS Well-Architected: Reliability.
- DynamoDB Developer Guide: Global Tables.
🔍 Phân tích tất cả các phương án (đúng/sai)
Dưới đây là phân tích từng lựa chọn một cách chi tiết, giữ nguyên văn bản gốc tiếng Anh. Mỗi phương án được đánh giá dựa trên tính phù hợp với yêu cầu zero session loss khi EC2 fail.
-
Use sticky sessions with an Elastic Load Balancer target group.
❌ Sai: Sticky sessions (session affinity) buộc traffic của một session gắn bó với instance cụ thể (dùng cookie), giúp maintain state nhưng không fault-tolerant. Nếu instance fail, session cục bộ mất hoàn toàn. Không giải quyết vấn đề lưu trữ persistent. (AWS ALB hỗ trợ sticky nhưng warn về rủi ro single point of failure). -
Use Amazon SQS to save session data.
❌ Sai: SQS là message queue cho decoupling/asynchronous processing, không phù hợp lưu session vì: (1) Không hỗ trợ fast lookups (polling delay), (2) Không atomic reads/writes cho session, (3) Designed for fire-and-forget, không persistent cho real-time access. Session cần low-latency sync, SQS sẽ gây lag và potential loss. -
Use Amazon DynamoDB to perform scalable session handling.
✅ Đúng: Như đã giải thích ở trên. Scalable (auto-provisioned capacity), handles millions of sessions/sec, zero-downtime failover. Best practice cho microservices (kết hợp ELB + Lambda nếu cần). -
Use Elastic Load Balancer connection draining to stop sending requests to failing instances.
❌ Sai: Connection draining (deregistration delay) chỉ graceful shutdown traffic đến instance failing (cho phép complete requests đang chạy), không lưu session data. Session vẫn cục bộ trên instance, mất nếu fail đột ngột. Đây là tính năng ELB giúp high availability nhưng không address session persistence.
🏆 Kết luận & Best Practices
✅ Khuyến nghị triển khai: Kết hợp DynamoDB + DAX (in-memory cache) cho sub-ms latency, + ALB target groups cho load balancing. Test với Chaos Engineering (AWS Fault Injection Simulator). Điều này đảm bảo 99.999999999% durability theo SLA DynamoDB (cập nhật 2026).
Nếu cần code sample (Node.js/Python với AWS SDK), hãy cho tôi biết! 🚀
How should the developer manage the deployment of the new version?
- A Modify the CloudFormation template to include a Transform section and the AWS::CodeDeploy::BlueGreen hook.
- B Deploy the new version in a new CloudFormation stack. After testing is complete, update the application's DNS records for the new stack.
- C Run CloudFormation stack updates on the application stack to deploy new application versions when they are available.
- D Create a nested stack for the new version. Include a Transform section and the AWS::CodeDeploy::BlueGreen hook.
Xem giải thích
🧩 Phân tích chi tiết nội dung câu hỏi
Câu hỏi mô tả tình huống:
Một lập trình viên đang tạo các template AWS CloudFormation để quản lý việc triển khai ứng dụng trên Amazon Elastic Container Service (Amazon ECS) thông qua AWS CodeDeploy. Mục tiêu là tự động triển khai phiên bản mới của ứng dụng đến một phần trăm người dùng (percentage of users) trước khi phiên bản đó có sẵn cho tất cả người dùng.
Điều này ám chỉ nhu cầu về blue/green deployment với traffic shifting kiểu Canary (triển khai dần dần, ví dụ: 10% traffic trước, sau đó tăng dần), giúp giảm rủi ro bằng cách kiểm tra phiên bản mới trên một phần nhỏ traffic trước khi rollout toàn bộ. Đây là tính năng được hỗ trợ bởi AWS CodeDeploy cho ECS trong CloudFormation, sử dụng hook chuyên biệt để tự động hóa quá trình này mà không cần can thiệp thủ công.
🛠️ Bối cảnh kỹ thuật cập nhật đến 2026:
Theo tài liệu AWS mới nhất (AWS CloudFormation User Guide và AWS CodeDeploy Developer Guide, cập nhật 2024-2026), blue/green deployment trên ECS qua CodeDeploy hỗ trợ Canary (traffic shifting theo tỷ lệ phần trăm) và Linear (tăng dần theo thời gian). Điều này được tích hợp trực tiếp vào CloudFormation template thông qua Transform section và AWS::CodeDeploy::BlueGreen hook, cho phép deployment tự động, rollback an toàn nếu có lỗi.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Modify the CloudFormation template to include a Transform section and the AWS::CodeDeploy::BlueGreen hook.
Lý do:
🟢 Phương án này sử dụng Transform: 'AWS::CodeDeployBlueGreen' trong CloudFormation template, kết hợp với AWS::CodeDeploy::BlueGreen hook trên ECS service. Hook này kích hoạt CodeDeploy blue/green deployment, hỗ trợ Canary traffic shifting (ví dụ: 10% traffic đến blue environment trước, sau monitor và shift dần đến 100%). Đây là cách tự động và native nhất cho ECS, phù hợp chính xác với yêu cầu "deploy to a percentage of users before all users". Không cần stack mới hay cập nhật thủ công, đảm bảo zero-downtime và rollback tự động nếu metrics kém.
📘 Tài liệu tham khảo:
- AWS Documentation: Deploying an Amazon ECS blue/green deployment with CodeDeploy and AWS CloudFormation
- AWS CloudFormation: AWS::CodeDeploy::BlueGreen Hook (cập nhật 2025).
📋 Giải thích tất cả các phương án (đúng/sai)
Dưới đây là phân tích chi tiết từng lựa chọn, giữ nguyên nội dung gốc bằng tiếng Anh. Mỗi phương án được đánh giá với lý do cụ thể dựa trên best practices AWS DevOps.
-
Modify the CloudFormation template to include a Transform section and the AWS::CodeDeploy::BlueGreen hook.
✅ Đúng 🟢: Như đã giải thích ở trên, đây là cách chính xác để kích hoạt blue/green với Canary deployment trên ECS. Transform section định nghĩa lifecycle hooks, tự động route traffic theo phần trăm (scale-in/out), monitor CloudWatch metrics, và switch ALB target groups. -
Deploy the new version in a new CloudFormation stack. After testing is complete, update the application's DNS records for the new stack.
❌ Sai 🔴: Phương án này yêu cầu tạo stack mới thủ công, test riêng, rồi cập nhật DNS (Route 53) để switch traffic. Không tự động, không hỗ trợ percentage rollout (chỉ all-or-nothing), dễ gây downtime, phức tạp quản lý (nhiều stack), và không tích hợp CodeDeploy/ECS native. Phù hợp manual deployment hơn là automated canary. -
Run CloudFormation stack updates on the application stack to deploy new application versions when they are available.
❌ Sai 🔴: CloudFormation stack updates chỉ deploy in-place (rolling updates trên ECS tasks), không hỗ trợ blue/green hay percentage traffic shifting. Sẽ ảnh hưởng toàn bộ users ngay lập tức, không có giai đoạn test gradual, rủi ro cao nếu version mới lỗi (không rollback dễ dàng như CodeDeploy hook). -
Create a nested stack for the new version. Include a Transform section and the AWS::CodeDeploy::BlueGreen hook.
❌ Sai 🔴: Nested stack hữu ích cho modularity, nhưng không cần thiết và sai ngữ cảnh ở đây. BlueGreen hook phải áp dụng trên stack chính chứa ECS service, không phải nested stack riêng cho version mới (dẫn đến không trigger CodeDeploy deployment đúng cách). Phức tạp hóa mà không giải quyết automated percentage rollout trên stack gốc.
💡 Lời khuyên DevOps: Sử dụng AWS::CodeDeployBlueGreen để đạt zero-downtime, canary deployment – best practice cho production ECS apps đến 2026! Nếu cần code sample, tham khảo AWS Samples trên GitHub.
Which combination of steps should the developer take to meet this requirement? (Choose two.)
- A Download the AWS X-Ray daemon. Install the daemon on an EC2 instance. Ensure that the EC2 instance allows UDP traffic on port 2000.
- B Configure an interface VPC endpoint to allow traffic to reach the global AWS X-Ray daemon on TCP port 2000.
- C Enable AWS X-Ray. Configure Amazon CloudWatch to push logs to X-Ray.
- D Add the AWS X-Ray software development kit (SDK) to the microservices. Use X-Ray to trace requests that each microservice makes.
- E Set up Amazon CloudWatch metric streams to collect streaming data from the microservices.
Xem giải thích
🧩 Giải thích nội dung câu hỏi
Câu hỏi mô tả một lập trình viên đã phát triển ứng dụng phân tán sử dụng microservices chạy trên Amazon EC2 instances. Vấn đề chính là do volume tin nhắn lớn, không thể khớp (match) output log từ từng microservice với một transaction cụ thể. Mục tiêu là analyze message flow để debug ứng dụng.
📌 Yêu cầu chọn TWO steps kết hợp để giải quyết: Cần công cụ theo dõi (trace) luồng request qua các microservice, giúp visualize và correlate traces với transactions. Giải pháp chuẩn AWS là sử dụng AWS X-Ray, hỗ trợ tracing distributed applications (cập nhật mới nhất đến 2026, X-Ray vẫn là service chính cho tracing microservices trên EC2).
✅ Đáp án đúng (chọn TWO)
Hai phương án đúng là:
- Download the AWS X-Ray daemon. Install the daemon on an EC2 instance. Ensure that the EC2 instance allows UDP traffic on port 2000.
- Add the AWS X-Ray software development kit (SDK) to the microservices. Use X-Ray to trace requests that each microservice makes.
Lý do lựa chọn:
🛠️ Để trace message flow hiệu quả, cần AWS X-Ray SDK tích hợp vào code microservices (hỗ trợ nhiều ngôn ngữ như Java, Node.js, Python...) để capture traces/subsegments cho mỗi request/transaction. SDK gửi dữ liệu trace qua UDP port 2000 đến X-Ray daemon chạy trên cùng EC2 instance. Daemon thu thập, batch và forward traces đến X-Ray service qua HTTPS. Security group phải allow UDP/2000 inbound cho daemon nhận data từ SDK. Kết hợp này tạo end-to-end trace graph, giúp debug chính xác flow giữa microservices mà không phụ thuộc log matching thủ công.
📋 Phân tích chi tiết tất cả các phương án
Dưới đây là phân tích từng lựa chọn, giữ nguyên văn bản gốc bằng tiếng Anh. Mỗi phương án được đánh dấu ✅ (đúng) hoặc ❌ (sai), kèm giải thích rõ ràng:
-
✅ Download the AWS X-Ray daemon. Install the daemon on an EC2 instance. Ensure that the EC2 instance allows UDP traffic on port 2000.
🛠️ Đúng: Đây là bước bắt buộc cho EC2 (không dùng Lambda/Fargate). Daemon chạy như process riêng trên instance, lắng nghe UDP/2000 từ SDK để nhận trace segments. Phải config security group allow UDP/2000 inbound. Không có daemon, SDK không gửi được data (theo docs AWS X-Ray 2026). -
❌ Configure an interface VPC endpoint to allow traffic to reach the global AWS X-Ray daemon on TCP port 2000.
🚫 Sai: X-Ray không dùng interface VPC endpoint (interface dùng cho private API như S3/ECR). Thay vào đó dùng Gateway VPC endpoint cho X-Ray (prefixcom.amazonaws.region.xray). Daemon gửi data đến service qua HTTPS (TLS 443), không phải TCP/2000 (2000 chỉ là UDP nội bộ app-daemon). Không liên quan "global daemon". -
❌ Enable AWS X-Ray. Configure Amazon CloudWatch to push logs to X-Ray.
🚫 Sai: X-Ray chỉ trace requests/API calls, không nhận/push logs từ CloudWatch. CloudWatch Logs và X-Ray là dịch vụ riêng; không có integration trực tiếp "push logs to X-Ray". Để correlate, dùng X-Ray insights hoặc embed trace ID vào logs thủ công, nhưng không giải quyết trace flow. -
✅ Add the AWS X-Ray software development kit (SDK) to the microservices. Use X-Ray to trace requests that each microservice makes.
🛠️ Đúng: SDK instrument code để tự động trace HTTP calls, DB queries, AWS SDK calls giữa microservices. Tạo trace map visualize message flow, match theo transaction ID. Phải kết hợp daemon để hoàn chỉnh (cập nhật SDK v3+ hỗ trợ async/non-blocking traces). -
❌ Set up Amazon CloudWatch metric streams to collect streaming data from the microservices.
🚫 Sai: CloudWatch Metric Streams dùng để stream metrics real-time đến đích như S3/Prometheus, không trace request flow hay correlate transactions. Metrics chỉ là aggregate (CPU, latency), không chi tiết như traces của X-Ray.
📘 Tài liệu tham khảo (AWS cập nhật mới nhất 2026)
- AWS X-Ray Developer Guide: Using the AWS X-Ray daemon with EC2 – Chi tiết daemon config UDP/2000.
- Instrumenting code with X-Ray SDK: AWS X-Ray SDKs.
- VPC Endpoints for X-Ray: Gateway endpoints.
- Best practices microservices tracing: AWS Well-Architected Framework - Observability Pillar (2024 update).
Hy vọng phân tích này giúp bạn ôn thi DOP-C02 hiệu quả! 🚀 Nếu cần thêm ví dụ code/config, hỏi nhé!
Which method will meet these requirements with the LEAST operational overhead?
- A Build the application by using shell scripts to create .zip files for each Lambda function. Manually upload the .zip files to the AWS Management Console.
- B Build the application by using the AWS Serverless Application Model (AWS SAM). Use a continuous integration and continuous delivery (CI/CD) pipeline and the SAM CLI to deploy the Lambda functions.
- C Build the application by using shell scripts to create .zip files for each Lambda function. Upload the .zip files. Deploy the .zip files as Lambda functions by using the AWS CLI in a continuous integration and continuous delivery (CI/CD) pipeline.
- D Build a container for each Lambda function. Store the container images in AWS CodeArtifact. Deploy the containers as Lambda functions by using the AWS CLI in a continuous integration and continuous delivery (CI/CD) pipeline.
Xem giải thích
🧩 Giải thích chi tiết nội dung câu hỏi
Câu hỏi tập trung vào việc triển khai một ứng dụng serverless trên AWS, cụ thể là AWS Lambda functions cùng với infrastructure phụ thuộc (như API Gateway, DynamoDB, S3, v.v.). Yêu cầu chính là:
- Tự động hóa (automated way) việc deploy.
- Ít nỗ lực code nhất (minimum coding effort).
- Độ tin cậy cao (reliable).
- Chi phí vận hành thấp nhất (LEAST operational overhead), nghĩa là giảm thiểu công sức quản lý thủ công, bảo trì script, và lỗi con người.
🔍 Bối cảnh: Serverless yêu cầu deploy không chỉ code Lambda mà còn tài nguyên liên quan. Phương pháp lý tưởng phải hỗ trợ Infrastructure as Code (IaC), tích hợp CI/CD, và abstraction cao để developer không phải viết nhiều code thủ công. AWS khuyến nghị các tool như AWS SAM (Serverless Application Model) cho trường hợp này, vì nó đơn giản hóa việc định nghĩa và deploy toàn bộ stack serverless chỉ qua YAML template (dựa trên AWS CloudFormation).
📘 Tài liệu tham khảo:
- AWS SAM Developer Guide (cập nhật 2024-2026): docs.aws.amazon.com/serverless-application-model
- AWS Well-Architected Framework - Serverless Lens: Nhấn mạnh SAM cho low-overhead deployment.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Build the application by using the AWS Serverless Application Model (AWS SAM). Use a continuous integration and continuous delivery (CI/CD) pipeline and the SAM CLI to deploy the Lambda functions.
Lý do 🛠️:
- AWS SAM là framework chính thức của AWS dành riêng cho serverless, cho phép định nghĩa Lambda + infra chỉ qua file
template.yamlđơn giản (abstraction của CloudFormation). Không cần code phức tạp. - SAM CLI hỗ trợ build, package, deploy tự động (lệnh
sam deploy), test local, và tích hợp dễ dàng với CI/CD (AWS CodePipeline, GitHub Actions). - Least operational overhead: Tự động hóa toàn bộ (zip code, IAM roles, events), reliable nhờ managed CloudFormation stacks, và scale theo serverless best practices.
- Cập nhật 2026: SAM hỗ trợ Lambda SnapStart, Provisioned Concurrency, và container images native, giữ vị thế top choice cho serverless.
📋 Phân tích tất cả các phương án trả lời
Dưới đây là phân tích từng lựa chọn một cách chi tiết. Tôi giữ nguyên văn bản gốc tiếng Anh của phương án, đánh dấu ✅ (đúng) hoặc ❌ (sai), và giải thích lý do bằng tiếng Việt rõ ràng:
-
❌ [SAI] Build the application by using shell scripts to create .zip files for each Lambda function. Manually upload the .zip files to the AWS Management Console. 🧨 Lý do sai: Phương pháp thủ công hoàn toàn (manual upload qua Console), không tự động hóa deploy infra phụ thuộc. Overhead cao: Phải viết shell scripts tạo zip, upload từng file, không CI/CD, dễ lỗi scale (nhiều Lambda), không reliable (không rollback tự động). Vi phạm "automated" và "least overhead".
-
✅ [ĐÚNG] Build the application by using the AWS Serverless Application Model (AWS SAM). Use a continuous integration and continuous delivery (CI/CD) pipeline and the SAM CLI to deploy the Lambda functions. 🛠️ Lý do đúng: Như đã giải thích ở trên. SAM + SAM CLI + CI/CD là best practice AWS cho serverless: Tự động build/package/deploy toàn bộ stack, ít code (chỉ YAML), reliable qua CloudFormation changesets. Overhead thấp nhất, phù hợp mọi scale.
-
❌ [SAI] Build the application by using shell scripts to create .zip files for each Lambda function. Upload the .zip files. Deploy the .zip files as Lambda functions by using the AWS CLI in a continuous integration and continuous delivery (CI/CD) pipeline. 🚫 Lý do sai: Dù có CI/CD và AWS CLI (
aws lambda create-function), vẫn phải viết shell scripts thủ công tạo zip/upload S3 cho mỗi Lambda, không tự động hóa infra (API Gateway, etc.). Overhead cao: Bảo trì scripts phức tạp, dễ lỗi versioning/IAM, kém reliable so với IaC native như SAM. Không "minimum coding effort". -
❌ [SAI] Build a container for each Lambda function. Store the container images in AWS CodeArtifact. Deploy the containers as Lambda functions by using the AWS CLI in a continuous integration and continuous delivery (CI/CD) pipeline. 🛑 Lý do sai: Lambda hỗ trợ container images (từ 2020, cập nhật 2026 vẫn vậy), nhưng CodeArtifact là cho software artifacts (Maven/NPM), KHÔNG phải container registry (dùng ECR mới đúng). Phải build container thủ công cho mỗi Lambda → coding effort cao, overhead lớn (quản lý Dockerfiles, ECR push). Không tối ưu cho serverless thuần (zip nhanh hơn), kém reliable nếu infra không IaC. SAM hỗ trợ container tốt hơn mà ít effort hơn.
🎯 Kết luận và khuyến nghị
Phương pháp AWS SAM là lựa chọn optimal cho serverless theo AWS DevOps best practices (giảm 70-80% effort so với manual theo case studies). Để triển khai thực tế: Cài SAM CLI (brew install aws-sam-cli), viết template.yaml, tích hợp CodePipeline. Nếu cần scale lớn, kết hợp AWS CDK cho SAM! 🚀
📘 Nguồn bổ sung:
- AWS CI/CD for Serverless: docs.aws.amazon.com/lambda/latest/dg/lambda-cicd.html
- SAM CLI Guide (2026): Hỗ trợ Arm64, OpenTelemetry native.
Which application architecture pattern would enable the data to be processed as it is received?
- A Event driven
- B Client-server driven
- C Fan-out driven
- D Schedule driven
Xem giải thích
🧩 Giải thích nội dung câu hỏi
Câu hỏi mô tả một tình huống thực tế trong phát triển ứng dụng AWS: Một lập trình viên cần thay đổi kiến trúc ứng dụng để đáp ứng yêu cầu mới về thời gian xử lý dữ liệu. Dữ liệu gốc được lưu trữ trong Amazon DynamoDB và hiện đang được xử lý theo batch hàng đêm (nightly batch) để phân tích. Tuy nhiên, các nhà phân tích hệ thống (system analysts) không muốn chờ đợi đến ngày hôm sau mà yêu cầu dữ liệu được xử lý và sẵn sàng gần thời gian thực (near-real time) ngay khi dữ liệu được nhận vào.
🛠️ Vấn đề cốt lõi: Hệ thống hiện tại là xử lý theo lịch trình cố định (batch processing), dẫn đến độ trễ cao. Cần một kiến trúc pattern cho phép xử lý dữ liệu ngay lập tức khi nó được nhận (as it is received), tức là chuyển từ xử lý theo lịch sang xử lý dựa trên sự kiện (event-based). Điều này phù hợp với các dịch vụ AWS như DynamoDB Streams kết hợp AWS Lambda để trigger xử lý tự động, đảm bảo near-real time mà không cần polling thủ công (áp dụng kiến thức AWS cập nhật đến 2026, với DynamoDB Streams hỗ trợ replication đa vùng và Lambda hỗ trợ Provisioned Concurrency cho độ trễ thấp hơn).
✅ Đáp án đúng: Event driven
Lý do lựa chọn:
- Pattern Event driven (kiến trúc hướng sự kiện) cho phép hệ thống phản ứng ngay lập tức với các sự kiện (events) như dữ liệu mới được ghi vào DynamoDB.
- 🛠️ Cụ thể: Sử dụng DynamoDB Streams để capture thay đổi dữ liệu thời gian thực, sau đó trigger AWS Lambda hoặc Amazon EventBridge để xử lý và đẩy dữ liệu đến hệ thống phân tích (ví dụ: Amazon Kinesis, S3, hoặc Athena) mà không cần chờ batch hàng đêm.
- Điều này đáp ứng chính xác yêu cầu "processed as it is received" với độ trễ chỉ vài giây, scalable và serverless, phù hợp best practice AWS Well-Architected Framework (Reliability & Performance Efficiency pillars, cập nhật 2026).
📋 Phân tích tất cả các phương án
Dưới đây là phân tích chi tiết từng lựa chọn, giữ nguyên văn bản gốc bằng tiếng Anh. Mỗi phương án được đánh giá đúng/sai dựa trên tính phù hợp với yêu cầu near-real time processing từ DynamoDB.
-
Event driven ✅ Đúng:
Như đã giải thích ở trên, đây là pattern lý tưởng cho xử lý dữ liệu streaming ngay khi nhận. DynamoDB Streams + Lambda/EventBridge tạo luồng sự kiện tự động, đảm bảo near-real time mà không phụ thuộc lịch trình. Không có độ trễ batch, hỗ trợ scale tự động theo workload. -
Client-server driven ❌ Sai:
Pattern này tập trung vào giao tiếp trực tiếp giữa client và server (như request-response model), không hỗ trợ xử lý dữ liệu bất đồng bộ hoặc near-real time từ nguồn lưu trữ như DynamoDB. Nó phù hợp cho ứng dụng web truyền thống nhưng sẽ yêu cầu client polling liên tục, gây lãng phí tài nguyên và không giải quyết vấn đề batch delay. -
Fan-out driven ❌ Sai:
Fan-out là một kỹ thuật trong kiến trúc phân tán (ví dụ: SNS/SQS fan-out để replicate message đến nhiều subscriber), nhưng nó chỉ là phần con của event-driven chứ không phải pattern chính để xử lý dữ liệu ngay khi nhận. Không giải quyết gốc rễ vấn đề chuyển từ batch sang real-time, và có thể tạo độ phức tạp không cần thiết nếu không kết hợp streams. -
Schedule driven ❌ Sai:
Đây chính là pattern hiện tại của hệ thống (nightly batch với CloudWatch Events hoặc EventBridge Scheduler), dựa trên lịch trình cố định (cron-like). Nó gây độ trễ lớn (chờ đến ngày hôm sau), hoàn toàn trái ngược yêu cầu near-real time. AWS khuyến nghị tránh cho workload real-time từ 2023+.
📘 Tài liệu tham khảo
- AWS Documentation - Event-Driven Architecture: aws.amazon.com/event-driven-architecture (cập nhật 2026, ví dụ DynamoDB Streams + Lambda).
- DynamoDB Streams Developer Guide: docs.aws.amazon.com/amazondynamodb/latest/developerguide/Streams.html (hỗ trợ near-real time capture changes).
- AWS Well-Architected Framework - Serverless Lens: aws.amazon.com/architecture/well-architected (nhấn mạnh event-driven cho real-time processing).
- Exam Prep DOP-C02: AWS Certified DevOps Engineer Professional (patterns trong Serverless & Data Analytics domains).
Hy vọng phân tích này giúp bạn ôn thi hiệu quả! 🚀 Nếu cần ví dụ code Lambda hoặc diagram architecture, hãy hỏi thêm nhé!