Ngân hàng đề — AWS Certified Developer Associate
Tìm thấy 1356 câu.
The company must rotate the database credentials every 2 weeks. Lambda functions that the company deployed previously must be able to use the most recent credentials.
Which solution will meet these requirements?
- A Store the database credentials in AWS Secrets Manager. Turn on rotation. Write code in the Lambda function to retrieve the credentials from Secrets Manager.
- B Include the database credentials as part of the Lambda function code. Update the credentials periodically and deploy the new Lambda function.
- C Use Lambda environment variables. Update the environment variables when new credentials are available.
- D Store the database credentials in AWS Systems Manager Parameter Store. Turn on rotation. Write code in the Lambda function to retrieve the credentials from Systems Manager Parameter Store.
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 việc triển khai một static website trên Amazon S3 cho môi trường production, tích hợp với Amazon Aurora PostgreSQL database thông qua AWS Lambda function. Website sử dụng Lambda alias trỏ đến một version cụ thể của Lambda function. Yêu cầu chính là xoay vòng (rotate) credentials database mỗi 2 tuần, đồng thời đảm bảo các Lambda functions đã deploy trước đó (bao gồm các version cũ) vẫn có thể sử dụng credentials mới nhất mà không cần thay đổi code hoặc redeploy.
🔑 Thách thức cốt lõi:
- Credentials phải được quản lý an toàn và tự động rotate định kỳ.
- Vì sử dụng Lambda alias với specific version, các version Lambda cũ không thể thay đổi code, environment variables hoặc config tĩnh → cần cơ chế retrieve credentials động từ nguồn bên ngoài.
- Giải pháp phải tuân thủ best practices AWS về security (như nguyên tắc least privilege và automated secret rotation).
📘 Kiến thức AWS cập nhật đến 2026: AWS Secrets Manager hỗ trợ rotation tự động cho Aurora PostgreSQL (tích hợp native với RDS), Lambda có thể dùng IAM roles để retrieve secrets runtime. Parameter Store hỗ trợ rotation cơ bản nhưng kém linh hoạt hơn cho DB secrets.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Store the database credentials in AWS Secrets Manager. Turn on rotation. Write code in the Lambda function to retrieve the credentials from Secrets Manager.
Lý do chi tiết 🛠️:
- AWS Secrets Manager được thiết kế chuyên biệt cho việc lưu trữ và xoay vòng secrets (bao gồm DB credentials), hỗ trợ automatic rotation mỗi 2 tuần qua Lambda rotator tích hợp sẵn cho Aurora PostgreSQL.
- Lambda function code retrieve credentials động tại runtime qua AWS SDK (ví dụ:
secretsmanager.getSecretValue()), nên tất cả Lambda versions cũ (kể cả qua alias specific version) đều lấy được credentials mới nhất mà không cần redeploy. - An toàn cao: Sử dụng IAM role với policy
secretsmanager:GetSecretValue, hỗ trợ caching và versioning secrets. - Tuân thủ AWS Well-Architected Framework (Security Pillar).
📋 Giải thích tất cả các phương án (đúng/sai)
-
Store the database credentials in AWS Secrets Manager. Turn on rotation. Write code in the Lambda function to retrieve the credentials from Secrets Manager.
✅ Đúng vì: Như phân tích trên, đây là giải pháp chuẩn AWS cho rotation DB secrets. Lambda retrieve động đảm bảo backward compatibility với versions cũ. Hỗ trợ Aurora PostgreSQL native rotation (tạo new user/role nếu cần). -
Include the database credentials as part of the Lambda function code. Update the credentials periodically and deploy the new Lambda function.
❌ Sai vì: Hardcode credentials vào code vi phạm nguyên tắc security (dễ leak qua code repo hoặc logs). Phải redeploy Lambda version mới mỗi 2 tuần → alias specific version cũ sẽ không update, dẫn đến downtime hoặc credentials cũ. Không scalable và không automated. -
Use Lambda environment variables. Update the environment variables when new credentials are available.
❌ Sai vì: Environment variables là tĩnh, phải update thủ công qua console/CLI/API → không tự động rotate. Với specific Lambda version, env vars không thay đổi sau publish version → versions cũ vẫn dùng credentials cũ. Không an toàn bằng Secrets Manager (env vars có thể expose qua Lambda console). -
Store the database credentials in AWS Systems Manager Parameter Store. Turn on rotation. Write code in the Lambda function to retrieve the credentials from Systems Manager Parameter Store.
❌ Sai vì: Parameter Store hỗ trợ rotation cho SecureString qua custom Lambda rotator, nhưng không có native integration với Aurora PostgreSQL như Secrets Manager (phải tự viết rotator phức tạp). Chi phí thấp hơn nhưng kém hiệu quả cho DB rotation (không tự động quản lý DB user/password). AWS recommend Secrets Manager cho secrets động như DB creds (theo docs 2026).
📚 Tài liệu tham khảo (AWS cập nhật 2026)
- AWS Secrets Manager Rotation for Amazon RDS/Aurora ✅ Native support cho PostgreSQL.
- Lambda Best Practices for Working with Secrets 🛠️ Retrieve runtime.
- AWS Well-Architected Framework - Security Pillar 📘 Secret management.
- Systems Manager Parameter Store vs. Secrets Manager → Secrets Manager ưu tiên cho DB.
Giải pháp này đảm bảo zero-downtime rotation và security compliance! 🚀
Which methods could the developer use to complete a signed request? (Choose two.)
- A Add the signature to an HTTP header that is named Authorization.
- B Add the signature to a session cookie.
- C Add the signature to an HTTP header that is named Authentication.
- D Add the signature to a query string parameter that is named X-Amz-Signature.
- E Add the signature to an HTTP header that is named WWW-Authenticate.
Xem giải thích
🧩 Phân tích chi tiết nội dung câu hỏi
Câu hỏi này thuộc chủ đề AWS Signature Version 4 (SigV4), một cơ chế ký yêu cầu (signed requests) tiêu chuẩn để xác thực và ủy quyền khi ứng dụng gọi các dịch vụ AWS như S3, EC2, DynamoDB,... qua HTTP/HTTPS.
- Bối cảnh: Một lập trình viên đã hoàn thành các bước chính trong quy trình SigV4:
- Tạo canonical request (chuẩn hóa yêu cầu HTTP thành định dạng chuẩn).
- Tạo string to sign (chuỗi cần ký dựa trên canonical request).
- Tính toán signing information (signature bằng HMAC-SHA256).
- Yêu cầu: Chọn hai phương pháp để hoàn tất signed request bằng cách thêm signature vào yêu cầu HTTP gửi đến AWS.
- Mục tiêu kiểm tra: Hiểu rõ vị trí hợp lệ để đặt signature theo tài liệu AWS chính thức (không phải các header tùy tiện hoặc cookie).
Quy trình SigV4 yêu cầu signature phải được đặt ở vị trí cụ thể để AWS xác minh tính toàn vẹn và nguồn gốc yêu cầu. Kiến thức cập nhật đến 2026 vẫn giữ nguyên quy tắc này (không thay đổi lớn từ các phiên bản trước như 2014).
📘 Tài liệu tham khảo:
- AWS Signature Version 4 Signing Process (Chính thức AWS).
- Authenticating Requests (AWS SDKs).
✅ Đáp án đúng (Chọn 2)
Hai phương pháp đúng là:
-
Add the signature to an HTTP header that is named Authorization.
(Lý do: Đây là phương pháp chính cho SigV4 trong HTTP header, định dạng đầy đủ:Authorization: AWS4-HMAC-SHA256 Credential=..., SignedHeaders=..., Signature=...AWS sẽ kiểm tra header này đầu tiên.) -
Add the signature to a query string parameter that is named X-Amz-Signature.
(Lý do: Phương pháp thay thế cho query parameters, thường dùng với GET requests hoặc presigned URLs. Signature được mã hóa base64 và đặt vào paramX-Amz-Signature=...cùng các param khác nhưX-Amz-Credential,X-Amz-Algorithm.)
🛠️ 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 bằng tiếng Anh, kèm lý do đúng/sai dựa trên quy trình SigV4 chuẩn:
-
✅ Add the signature to an HTTP header that is named Authorization.
Đúng: Đây là vị trí tiêu chuẩn chính cho SigV4 trong HTTP requests. AWS yêu cầu headerAuthorizationchứa đầy đủ thông tin credential, signed headers và signature. Nếu thiếu, yêu cầu sẽ bị từ chối với lỗi 403 Forbidden. Phù hợp cho hầu hết các HTTP methods (POST, PUT,...). -
❌ Add the signature to a session cookie.
Sai: SigV4 không hỗ trợ sử dụng cookie (HTTP cookies) để truyền signature. Cookie dùng cho session management, không phải xác thực AWS. AWS chỉ kiểm tra header/query params chuẩn, cookie sẽ bị bỏ qua dẫn đến lỗi xác thực. -
❌ Add the signature to an HTTP header that is named Authentication.
Sai: Không có headerAuthenticationchuẩn trong SigV4. AWS chỉ chấp nhậnAuthorizationhoặc query params. Header này có thể bị nhầm với các protocol khác (như Basic Auth), nhưng SigV4 loại trừ hoàn toàn. -
✅ Add the signature to a query string parameter that is named X-Amz-Signature.
Đúng: Phương pháp query parameter signing hợp lệ cho SigV4, đặc biệt khi không dùng body (như GET) hoặc presigned URLs (S3). Các param bắt buộc:X-Amz-Algorithm=AWS4-HMAC-SHA256,X-Amz-Credential,X-Amz-Date,X-Amz-SignedHeaders, vàX-Amz-Signature. AWS ưu tiên kiểm tra query nếu header Authorization thiếu. -
❌ Add the signature to an HTTP header that is named WWW-Authenticate.
Sai: HeaderWWW-Authenticatelà response header từ server (challenge cho auth), không dùng để gửi signature từ client. SigV4 không định nghĩa header này cho request signing, sử dụng sẽ gây lỗi xác thực ngay lập tức.
Lưu ý thực hành 🚀: Trong code (SDK như Boto3/Python, AWS CLI), hai cách trên được tự động hóa. Luôn test với AWS IAM policies để tránh lỗi "SignatureDoesNotMatch". Nếu dùng presigned URLs, ưu tiên query params!
Which solution will meet these requirements with the LEAST development effort?
- A Create an AWS Lambda-backed CloudFormation custom resource. Write Lambda code that generates a secure string. Return the value of the secure string as a data field of the custom resource response object. Use the CloudFormation Fn::GetAtt intrinsic function to get the value of the secure string. Use the value to create the DB instance.
- B Use the AWS CodeBuild action of CodePipeline to generate a secure string by using the following AWS CLI command: aws secretsmanager get-random-password. Pass the generated secure string as a CloudFormation parameter with the NoEcho attribute set to true. Use the parameter reference to create the DB instance.
- C Create an AWS Lambda-backed CloudFormation custom resource. Write Lambda code that generates a secure string. Return the value of the secure string as a data field of the custom resource response object. Use the CloudFormation Fn::GetAtt intrinsic function to get a value of the secure string. Create secrets in AWS Secrets Manager. Use the secretsmanager dynamic reference to use the value stored in the secret to create the DB instance.
- D Use the AWS::SecretsManager::Secret resource to generate a secure string. Store the secure string as a secret in AWS Secrets Manager. Use the secretsmanager dynamic reference to use the value stored in the secret to create the DB instance.
Xem giải thích
🧩 Giải thích nội dung câu hỏi
Câu hỏi tập trung vào việc triển khai Amazon RDS DB instances bằng AWS CloudFormation templates trong quy trình AWS CodePipeline CI/CD. Yêu cầu chính là tự động generate mật khẩu chính (primary password) cho DB instance ngay trong quá trình deploy, mà không cần effort phát triển lớn (LEAST development effort).
🔍 Chi tiết vấn đề:
- CloudFormation là công cụ IaC (Infrastructure as Code) để định nghĩa và deploy resources một cách declarative.
- Trong CI/CD với CodePipeline, template CloudFormation được sử dụng để provision RDS.
- Mật khẩu DB phải tự động tạo (secure string), không hardcode, và tích hợp mượt mà vào template mà không cần code custom phức tạp.
- Mục tiêu: Giải pháp đơn giản nhất, tận dụng native features của AWS để giảm thiểu custom code, phù hợp với best practice DevOps (immutable infrastructure, automation).
🛠️ Bối cảnh cập nhật 2026: AWS tiếp tục ưu tiên dynamic references và native resources trong CloudFormation (phiên bản mới nhất hỗ trợ AWS::SecretsManager::Secret với auto-generate password từ CloudFormation v2+). Điều này tránh custom resources (Lambda) vốn dễ lỗi và tốn effort maintain.
✅ Đáp án đúng: D
Use the AWS::SecretsManager::Secret resource to generate a secure string. Store the secure string as a secret in AWS Secrets Manager. Use the secretsmanager dynamic reference to use the value stored in the secret to create the DB instance.
Lý do lựa chọn:
- Đây là giải pháp native của CloudFormation, sử dụng resource AWS::SecretsManager::Secret để tự động generate secure password (qua thuộc tính
GenerateSecretString). - Password được lưu trực tiếp vào AWS Secrets Manager, sau đó dùng dynamic reference (
{{resolve:secretsmanager:SecretId:SecretName:password}}) để inject vào RDS resource (nhưMasterUserPassword). - LEAST development effort: Không cần viết code Lambda, không cần CodeBuild action, chỉ khai báo YAML/JSON trong template. Hoàn toàn declarative, an toàn (NoEcho tự động), và tích hợp liền mạch với CodePipeline.
- ✅ Ưu điểm: Hỗ trợ rotation tự động, audit trail qua Secrets Manager, và tuân thủ security best practices (AWS Well-Architected Framework - Security Pillar).
📋 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. Tôi đánh dấu ✅ đúng hoặc ❌ sai, kèm giải thích đầy đủ bằng tiếng Việt.
-
❌ A: Create an AWS Lambda-backed CloudFormation custom resource. Write Lambda code that generates a secure string. Return the value of the secure string as a data field of the custom resource response object. Use the CloudFormation Fn::GetAtt intrinsic function to get the value of the secure string. Use the value to create the DB instance.
- Tại sao sai? Phương án này yêu cầu viết code Lambda custom để generate password, implement CloudFormation custom resource handler (cần xử lý Create/Update/Delete events). Sử dụng
Fn::GetAttđể lấy giá trị, nhưng tốn nhiều effort dev/test/debug (Lambda code, permissions, error handling). Không phải "least effort" vì native features đã có sẵn. Dễ lỗi nếu Lambda fail.
- Tại sao sai? Phương án này yêu cầu viết code Lambda custom để generate password, implement CloudFormation custom resource handler (cần xử lý Create/Update/Delete events). Sử dụng
-
❌ B: Use the AWS CodeBuild action of CodePipeline to generate a secure string by using the following AWS CLI command: aws secretsmanager get-random-password. Pass the generated secure string as a CloudFormation parameter with the NoEcho attribute set to true. Use the parameter reference to create the DB instance.
- Tại sao sai? Phải thêm CodeBuild stage trong CodePipeline để chạy CLI
get-random-password, generate parameter động, rồi pass vào CloudFormation. Tăng complexity pipeline (buildspec.yaml, IAM roles cho CLI), không pure CloudFormation. Parameter vớiNoEcho=trueche giấu log nhưng vẫn expose trong pipeline artifacts. Không "least effort" vì cần maintain CodeBuild project riêng.
- Tại sao sai? Phải thêm CodeBuild stage trong CodePipeline để chạy CLI
-
❌ C: Create an AWS Lambda-backed CloudFormation custom resource. Write Lambda code that generates a secure string. Return the value of the secure string as a data field of the custom resource response object. Use the CloudFormation Fn::GetAtt intrinsic function to get a value of the secure string. Create secrets in AWS Secrets Manager. Use the secretsmanager dynamic reference to use the value stored in the secret to create the DB instance.
- Tại sao sai? Tương tự A, vẫn cần custom Lambda để generate và create secret trong Secrets Manager, dùng
Fn::GetAtt+ dynamic ref. Effort cao hơn A vì thêm bước create secret. Phức tạp hóa template với custom resource, dễ gặp race conditions hoặc permission issues. AWS khuyến cáo tránh custom resources nếu native có sẵn.
- Tại sao sai? Tương tự A, vẫn cần custom Lambda để generate và create secret trong Secrets Manager, dùng
-
✅ D: Use the AWS::SecretsManager::Secret resource to generate a secure string. Store the secure string as a secret in AWS Secrets Manager. Use the secretsmanager dynamic reference to use the value stored in the secret to create the DB instance.
- Tại sao đúng? Như đã giải thích ở trên: Zero custom code, chỉ dùng resource native
AWS::SecretsManager::SecretvớiGenerateSecretString(customizable length, chars). Dynamic ref inject trực tiếp vào RDSMasterUserPassword. Hoàn hảo cho CI/CD, scale tốt, và cập nhật 2026 hỗ trợ full integration với RDS Aurora Serverless v2+.
- Tại sao đúng? Như đã giải thích ở trên: Zero custom code, chỉ dùng resource native
📘 Tài liệu tham khảo (cập nhật 2026)
- AWS Docs - AWS::SecretsManager::Secret: docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-secretsmanager-secret.html – Chi tiết
GenerateSecretString. - Dynamic References: docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html#dynamic-references-secretsmanager – Hướng dẫn
{{resolve:secretsmanager:...}}. - RDS + Secrets Manager Best Practices: aws.amazon.com/blogs/security/use-aws-secrets-manager-to-rotate-rds-master-passwords/ (Well-Architected Labs).
- CloudFormation Updates 2025-2026: Processor Framework v2 cho custom resources, nhưng native preferred (AWS re:Invent 2025 announcements).
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ụ YAML template, hỏi thêm nhé!
What AWS service should be used to accomplish this?
- A Amazon DynamoDB
- B Amazon EC2
- C AWS Lambda
- D Amazon RDS
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ả một tổ chức đang lưu trữ file lớn trong Amazon S3, và họ đang phát triển một web application để hiển thị metadata (dữ liệu mô tả) về các file này cho người dùng cuối. Người dùng sẽ chọn một object dựa trên metadata để tải xuống. Yêu cầu chính là cần một cơ chế indexing (chỉ mục hóa) các file và cung cấp độ trễ truy xuất metadata chỉ trong khoảng single-digit millisecond (dưới 10ms, tức là cực kỳ nhanh).
📘 Tóm tắt vấn đề cốt lõi:
- S3 phù hợp lưu trữ file lớn, nhưng không tối ưu cho truy vấn metadata nhanh chóng.
- Cần dịch vụ AWS hỗ trợ indexing metadata và latency thấp cho web app.
✅ Đáp án đúng: Amazon DynamoDB
Lý do chọn DynamoDB 🛠️:
- DynamoDB là dịch vụ NoSQL database hoàn toàn quản lý (serverless), được thiết kế đặc biệt cho single-digit millisecond latency ở mọi quy mô, ngay cả với hàng tỷ records.
- Hoàn hảo để index metadata từ S3 objects (ví dụ: lưu key-value như file name, size, upload date làm partition/sort key).
- Tích hợp dễ dàng với S3 qua S3 Event Notifications hoặc Lambda để tự động sync metadata khi upload file.
- Theo cập nhật AWS 2026 (DynamoDB On-Demand capacity mode, Global Tables v2), nó hỗ trợ point-in-time recovery và adaptive capacity cho workload cao mà không cần provision.
📋 Giải thích tất cả các phương án (Đúng/Sai)
-
Amazon DynamoDB ✅ ĐÚNG
Như đã giải thích ở trên, DynamoDB đáp ứng chính xác yêu cầu indexing và low-latency retrieval (P99 latency <10ms). Lý tưởng cho metadata unstructured từ S3, scalable infinitely mà không downtime. -
Amazon EC2 ❌ SAI
EC2 là dịch vụ compute instance (máy ảo), không phải database hay indexing service. Bạn phải tự cài đặt và quản lý database (như self-hosted DB) trên EC2, dẫn đến latency cao hơn, tốn công quản lý scaling, backup, và không đảm bảo single-digit ms mà không optimize phức tạp. -
AWS Lambda ❌ SAI
Lambda là serverless compute cho function execution, không phải storage/indexing service. Nó có thể dùng để process metadata (ví dụ: trigger từ S3), nhưng không lưu trữ hoặc query nhanh metadata – bạn vẫn cần kết hợp với DB khác, và Lambda cold start có thể vượt quá single-digit ms. -
Amazon RDS ❌ SAI
RDS là relational database (SQL như MySQL/PostgreSQL), phù hợp structured data nhưng latency thường 10-50ms+ ở quy mô lớn, không optimized cho single-digit ms như DynamoDB. Indexing metadata có thể làm, nhưng kém hiệu quả với large-scale unstructured data từ S3, và yêu cầu provision instance gây overhead.
📚 Tài liệu tham khảo (Cập nhật AWS 2026)
- AWS Documentation: Amazon DynamoDB Developer Guide - Latency – Xác nhận P99 <10ms.
- AWS Well-Architected Framework: Pillar Reliability & Performance Efficiency – Khuyến nghị DynamoDB cho metadata indexing với S3.
- DOP-C02 Exam Guide (2024-2026): Domain 2: Storage & Compute – DynamoDB vs RDS/EC2 cho low-latency NoSQL.
- S3 + DynamoDB Integration: AWS Sample Architecture.
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 case study, hỏi nhé!
When the developer deploys the AWS SAM template in the eu-west-1 Region, the creation of the stack fails.
Which of the following could be the reason for this issue?
- A CloudFront distributions can be created only in the us-east-1 Region.
- B Lambda@Edge functions can be created only in the us-east-1 Region.
- C A single AWS SAM template cannot contain multiple Lambda functions.
- D The CloudFront distribution and the S3 bucket cannot be created in the same Region.
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 xây dựng AWS Serverless Application Model (AWS SAM) template bao gồm:
- Nhiều AWS Lambda functions (một trong số đó chạy trên Lambda@Edge tích hợp với Amazon CloudFront).
- Một Amazon S3 bucket được cấu hình làm origin cho CloudFront.
- Khi deploy template này ở Region eu-west-1 (Ireland), việc tạo stack thất bại.
Vấn đề cốt lõi: Stack CloudFormation (từ SAM) không deploy được ở region này. Lý do liên quan đến hạn chế region-specific của các dịch vụ AWS, đặc biệt là Lambda@Edge và CloudFront. SAM transform sẽ gọi CloudFormation để tạo resources, nhưng một số resources có ràng buộc về region. ✅ Kiến thức cập nhật đến 2026: Lambda@Edge vẫn chỉ hỗ trợ tạo và quản lý chính ở us-east-1, sau đó replicate global (theo AWS docs mới nhất).
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Lambda@Edge functions can be created only in the us-east-1 Region.
Lý do:
- Lambda@Edge là tính năng đặc biệt của Lambda, chỉ hoạt động với CloudFront, và chỉ có thể tạo/associate ở region us-east-1 (N. Virginia). Khi deploy ở region khác (như eu-west-1), CloudFormation sẽ fail vì Lambda@Edge không hỗ trợ tạo trực tiếp ở đó.
- SAM template sẽ cố tạo Lambda@Edge ở eu-west-1 → lỗi validation. Giải pháp: Deploy toàn bộ stack ở us-east-1, Lambda@Edge sẽ replicate tự động đến edge locations toàn cầu.
- Các resources khác (S3, Lambda thường, CloudFront) linh hoạt hơn, nhưng Lambda@Edge là "ngòi nổ" gây fail. 🛠️ Đây là best practice DevOps: Luôn kiểm tra region constraints trước khi deploy SAM/CloudFormation.
📋 Giải thí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, giữ nguyên văn bản 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 tài liệu AWS mới nhất:
-
❌ CloudFront distributions can be created only in the us-east-1 Region.
Sai vì: CloudFront có thể tạo ở bất kỳ region nào (global service), nhưng quản lý chính ở us-east-1. Deploy ở eu-west-1 vẫn OK, chỉ Lambda@Edge mới bị hạn chế. S3 origin có thể ở region khác mà không vấn đề. -
✅ Lambda@Edge functions can be created only in the us-east-1 Region.
Đúng vì: Lambda@Edge bắt buộc tạo ở us-east-1 để replicate đến 200+ edge locations. Deploy ở eu-west-1 gây lỗi "InvalidParameterValueException" hoặc tương tự trong CloudFormation. Đây chính là nguyên nhân stack fail. -
❌ A single AWS SAM template cannot contain multiple Lambda functions.
Sai vì: SAM hỗ trợ nhiều Lambda functions trong một template (dùngAWS::Serverless::Function). Giới hạn chỉ là quota tài nguyên AWS (ví dụ: 1000 functions/stack), không phải cấm multiple. -
❌ The CloudFront distribution and the S3 bucket cannot be created in the same Region.
Sai vì: CloudFront hỗ trợ S3 origin ở bất kỳ region nào (bao gồm cùng region). Không có ràng buộc này; S3 ở eu-west-1 làm origin cho CloudFront vẫn hoạt động bình thường.
📘 Tài liệu tham khảo (cập nhật 2026)
- AWS Lambda@Edge Docs: Lambda@Edge regions – Xác nhận "must be created in the US East (N. Virginia) Region".
- CloudFront Developer Guide: Lambda@Edge setup – "Replicate from us-east-1".
- AWS SAM Docs: SAM with CloudFront/Lambda@Edge.
- CloudFormation Limits: Regional endpoints.
🛠️ Tips DevOps: Để fix, dùng sam deploy --region us-east-1 hoặc tách Lambda@Edge thành stack riêng ở us-east-1, cross-reference bằng ARN. Test với sam build && sam validate trước! 🚀
Which caching strategy will meet these requirements?
- A A read-through cache
- B A write-behind cache
- C A lazy-loading cache
- D A write-through cache
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 tích hợp Amazon ElastiCache vào ứng dụng, nơi cache lưu trữ dữ liệu từ một cơ sở dữ liệu (database). Yêu cầu chính là dữ liệu trong cache phải được sử dụng để populate (điền dữ liệu) các dashboard thời gian thực (real-time dashboards).
📌 Ý nghĩa cốt lõi:
- ElastiCache (hỗ trợ Redis hoặc Memcached) cần một chiến lược caching đảm bảo tính nhất quán cao và cập nhật ngay lập tức, vì dashboard real-time đòi hỏi dữ liệu phải phản ánh thay đổi từ database mà không có độ trễ đáng kể.
- Theo tài liệu AWS mới nhất (cập nhật đến 2026), ElastiCache không tự động hỗ trợ tất cả chiến lược caching; developer phải implement logic ở application layer, nhưng các pattern chuẩn như write-through được khuyến nghị cho use case real-time.
✅ Đáp án đúng: A write-through cache
Lý do lựa chọn:
- 🛠️ Write-through đảm bảo mọi thay đổi dữ liệu (write/update) từ ứng dụng sẽ được ghi đồng thời vào cả cache và database. Kết quả: Cache luôn đồng bộ ngay lập tức với database, giúp dashboard real-time hiển thị dữ liệu mới nhất mà không cần refresh thủ công hoặc chờ đợi.
- Phù hợp hoàn hảo cho real-time dashboards vì tránh tình trạng dữ liệu cũ (stale data) trong cache.
- Theo AWS best practices (2026), pattern này giảm latency cho reads sau writes, lý tưởng cho analytics dashboards.
📋 Giải thí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, dựa trên đặc tính của ElastiCache và caching patterns chuẩn AWS:
-
❌ A read-through cache
Phương án này sai vì read-through chỉ hoạt động khi đọc (read) miss cache: cache tự động load dữ liệu từ database vào cache. Nó không đảm bảo cập nhật real-time khi database thay đổi (ví dụ: update không trigger write vào cache). Dashboard có thể hiển thị dữ liệu cũ nếu cache chưa được invalidate thủ công, dẫn đến độ trễ không chấp nhận được cho real-time. -
❌ A write-behind cache
Phương án này sai vì write-behind (hay write-back) ghi dữ liệu vào cache trước, sau đó async (bất đồng bộ) ghi vào database sau (có thể delay vài giây/phút). Điều này gây rủi ro mất dữ liệu nếu cache fail và không real-time, vì dashboard đọc từ cache có thể khác với database thực tế trong thời gian chờ sync. -
❌ A lazy-loading cache
Phương án này sai vì lazy-loading (hay cache-aside) chỉ load dữ liệu vào cache khi có read miss (on-demand). Nó phụ thuộc vào ứng dụng kiểm soát write/update, không tự động sync thay đổi từ database. Với real-time dashboards, read đầu tiên có thể chậm (phải query DB), và cache dễ bị stale nếu không implement eviction phức tạp. -
✅ A write-through cache
Như đã giải thích ở trên, đây là phương án đúng vì đảm bảo tính nhất quán mạnh (strong consistency) giữa cache và DB ngay lập tức, lý tưởng cho real-time use case.
📘 Tài liệu tham khảo (AWS cập nhật 2026)
- AWS ElastiCache Developer Guide: Caching Strategies – Chi tiết write-through vs. các pattern khác.
- AWS Best Practices for Caching: Real-time Analytics with ElastiCache – Khuyến nghị write-through cho dashboards.
- Exam Topic DOP-C02 (DevOps Pro 2026): Caching patterns trong ElastiCache là nội dung core, với write-through ưu tiên cho consistency.
Hy vọng phân tích này giúp bạn ôn thi hiệu quả! 🚀 Nếu cần thêm ví dụ code, hãy hỏi nhé!
Which solution will meet these requirements with the LEAST operational overhead?
- A Create a Lambda layer to store the external library. Configure the Lambda function to use the layer.
- B Create an Amazon S3 bucket. Upload the external library into the S3 bucket. Mount the S3 bucket folder in the Lambda function. Import the library by using the proper folder in the mount point.
- C Load the external library to the Lambda function's /tmp directory during deployment of the Lambda package. Import the library from the /tmp directory.
- D Create an Amazon Elastic File System (Amazon EFS) volume. Upload the external library to the EFS volume. Mount the EFS volume in the Lambda function. Import the library by using the proper folder in the mount point.
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 một tình huống thực tế trong AWS Lambda: Một lập trình viên đang tạo một Lambda function cần sử dụng thư viện ngoài (external library) để kết nối với giải pháp bên thứ ba (third-party solution). Thư viện này là tập hợp các file với tổng kích thước 100 MB.
Yêu cầu chính:
- ✅ Làm cho thư viện có sẵn trong môi trường thực thi (execution environment) của Lambda.
- ✅ Giảm kích thước gói triển khai (Lambda package space) – vì Lambda có giới hạn nghiêm ngặt: 50 MB zipped cho direct upload qua console/CLI, hoặc 250 MB unzipped khi dùng container image/ZIP qua S3 (cập nhật đến 2026, theo AWS Lambda limits).
- 📊 Giải pháp phải có LEAST operational overhead: Nghĩa là ít công sức quản lý nhất, dễ triển khai, bảo trì, scale tự động mà không cần cấu hình phức tạp như VPC, storage riêng, hoặc script tùy chỉnh.
🛠️ Vấn đề cốt lõi: Nếu nhồi thư viện vào package Lambda gốc, kích thước sẽ vượt quá giới hạn (100 MB zipped có thể unzip lớn hơn 250 MB), dẫn đến lỗi deployment. Cần cách tách biệt thư viện để reuse và giảm overhead.
📘 Tài liệu tham khảo:
- AWS Lambda Layers Documentation (cập nhật 2025).
- AWS Lambda Limits (deployment package sizes).
- Best Practices for Working with AWS Lambda Functions (layers cho large dependencies).
✅ Đáp án đúng: Create a Lambda layer to store the external library. Configure the Lambda function to use the layer.
Lý do lựa chọn:
- 🛡️ Lambda Layers là tính năng chuẩn AWS dành riêng cho việc lưu trữ code reuse, thư viện ngoài (như Python/Node.js packages) mà không tính vào kích thước package Lambda gốc. Layer có thể attach vào function dễ dàng qua console/CLI/Terraform.
- 📦 Giảm package space: Thư viện 100 MB nằm trong layer (hỗ trợ tối đa 5 layers per function, tổng unzipped ≤ 250 MB). Package Lambda chỉ còn code chính (rất nhỏ).
- 🚀 Least overhead: Tự động deploy, cache layer trên môi trường execution (giảm cold start), hỗ trợ version control, share cross-account/region. Không cần VPC, storage ngoài, hay script tải file.
- 🔄 Cập nhật 2026: Layers hỗ trợ runtime mới nhất (Python 3.12, Node.js 22), extension layers cho monitoring.
📋 Phân tích tất cả các phương án (đúng/sai)
-
✅ Create a Lambda layer to store the external library. Configure the Lambda function to use the layer.
Đúng hoàn toàn 🏆. Như đã giải thích, đây là giải pháp tối ưu nhất từ AWS, thiết kế dành riêng cho dependencies lớn. Overhead thấp: chỉ cần ZIP thư viện → publish layer → attach ARN vào function (1-2 bước CLI). Layers được cache globally, hiệu suất cao, dễ update version mà không redeploy function. -
❌ Create an Amazon S3 bucket. Upload the external library into the S3 bucket. Mount the S3 bucket folder in the Lambda function. Import the library by using the proper folder in the mount point.
Sai 🚫. Lambda không hỗ trợ mount S3 bucket trực tiếp như filesystem (S3 là object storage, không phải block/file system). Phải dùng thư viện bên thứ ba nhưs3fs-fusehoặc script tải file runtime (tăng cold start >10s), đòi hỏi IAM role phức tạp, VPC endpoint. Overhead cao: quản lý bucket, versioning, tải động → không scalable, không phải best practice. -
❌ Load the external library to the Lambda function's /tmp directory during deployment of the Lambda package. Import the library from the /tmp directory.
Sai 🚫./tmpchỉ 512 MB writable, reset mỗi invocation (không persistent). "Load during deployment" vẫn nhồi vào package → vượt limit 250 MB unzipped. Runtime phải copy từ code → tăng cold start, memory usage. Overhead cao: script tùy chỉnh mỗi deploy, không reuse cross-function → không giảm package space thực sự. -
❌ Create an Amazon Elastic File System (Amazon EFS) volume. Upload the external library to the EFS volume. Mount the EFS volume in the Lambda function. Import the library by using the proper folder in the mount point.
Sai 🚫. EFS có thể mount vào Lambda (từ 2020, VPC required), hỗ trợ shared storage. Nhưng overhead rất cao: setup VPC/subnet/security group, EFS access points, lifecycle policies, IAM/encryption. Chi phí ~$0.30/GB/tháng + throughput. Phù hợp large shared data (>TB), không phải 100 MB library → phức tạp hơn layers 10x, không "least overhead".
🛠️ Kết luận: Lambda Layers là best practice AWS-recommended cho dependencies lớn, tiết kiệm chi phí/time nhất! Nếu cần thực hành, dùng aws lambda publish-layer-version.
Which solution meets these requirements?
- A Clone the production environment to a different platform version. Deploy the new application code, and test it. Swap the environment URLs upon verification.
- B Deploy the new application code in an all-at-once deployment to the existing EC2 instances. Test the code. Redeploy the previous code if verification fails.
- C Perform an immutable update to deploy the new application code to new EC2 instances. Serve traffic to the new instances after they pass health checks.
- D Use a rolling deployment for the new application code. Apply the code to a subset of EC2 instances until the tests pass. Redeploy the previous code if the tests fail.
Xem giải thích
🧩 Phân tích nội dung câu hỏi
📖 Tổng quan câu hỏi:
Câu hỏi xoay quanh việc triển khai code ứng dụng mới và cập nhật phiên bản platform (từ Node.js cũ sang mới) trên môi trường Elastic Beanstalk (EB) sản xuất, với ứng dụng front-end chạy trên 4 instance EC2 sau Elastic Load Balancer (ELB). Yêu cầu chính là zero downtime (không gián đoạn dịch vụ), đồng thời cho phép test code mới.
🛠️ Thách thức kỹ thuật:
- EB quản lý môi trường (environment) tự động, bao gồm provisioning EC2, ELB, Auto Scaling.
- Cần deploy code mới + update platform version (Node.js) mà không downtime.
- Theo tài liệu AWS mới nhất (2024-2026), EB hỗ trợ các chính sách deployment như All-at-once, Rolling, Immutable, Blue/Green để đảm bảo tính sẵn sàng cao (high availability). Immutable deployment là lựa chọn lý tưởng cho zero-downtime khi thay đổi platform version lớn.
📘 Tài liệu tham khảo:
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Perform an immutable update to deploy the new application code to new EC2 instances. Serve traffic to the new instances after they pass health checks.
🧠 Lý do chi tiết:
Immutable update trong EB tạo ra một bộ instance EC2 mới hoàn toàn (parallel với production), deploy code mới + platform Node.js mới lên đó. EB chạy health checks trên instances mới; nếu pass, traffic tự động chuyển sang (qua CNAME swap hoặc ELB routing) mà không downtime. Nếu fail, rollback dễ dàng bằng cách discard instances mới. Điều này hoàn hảo cho zero-downtime khi update platform version lớn, vì platform change thường yêu cầu recreate instances. Đây là best practice theo AWS DOP-C02 (DevOps Professional 2024+).
🔍 Phân tích tất cả các phương án
-
✅ Perform an immutable update to deploy the new application code to new EC2 instances. Serve traffic to the new instances after they pass health checks.
🟢 Đúng vì: Như giải thích trên, immutable deployment đảm bảo zero-downtime bằng cách chạy parallel instances mới với platform + code mới, chỉ switch traffic sau health checks thành công. Hỗ trợ full platform upgrade (Node.js version). -
❌ Clone the production environment to a different platform version. Deploy the new application code, and test it. Swap the environment URLs upon verification.
🔴 Sai vì: Cloning environment tạo env mới, nhưng swap URLs (CNAME) gây downtime ngắn (thường 1-5 phút do DNS propagation). Không phải zero-downtime thực sự, và không tự động qua ELB như immutable. Phù hợp test nhưng không meet yêu cầu production zero-downtime. -
❌ Deploy the new application code in an all-at-once deployment to the existing EC2 instances. Test the code. Redeploy the previous code if verification fails.
🔴 Sai vì: All-at-once deploy dừng tất cả instances hiện tại để update, gây downtime hoàn toàn (dù ngắn). Không hỗ trợ platform Node.js upgrade mượt mà trên existing instances, và rollback không zero-downtime. Chỉ dùng cho non-critical env. -
❌ Use a rolling deployment for the new application code. Apply the code to a subset of EC2 instances until the tests pass. Redeploy the previous code if the tests fail.
🔴 Sai vì: Rolling deployment update dần batch instances (ví dụ 25% mỗi lần), nhưng có thể gây partial downtime hoặc capacity giảm tạm thời (nếu batch fail health checks). Không lý tưởng cho platform version change lớn (cần recreate instances), và không đảm bảo zero-downtime tuyệt đối như immutable.
💡 Lời khuyên DevOps: Để triển khai thực tế, dùng EB Console/CLI với --deployment-policy Immutable, kết hợp CloudWatch alarms cho health checks. Test trước trên staging env! 🚀
How can the developer unit test the function?
- A Create an AWS CloudFormation template that creates an SQS queue and deploys the Lambda function. Create a stack from the template during the CI/CD process. Invoke the deployed function. Verify the output.
- B Create an SQS event for tests. Use a test that consumes messages from the SQS queue during the function's Cl/CD process.
- C Create an SQS queue for tests. Use this SQS queue in the application's unit test. Run the unit tests during the CI/CD process.
- D Use the aws lambda invoke command with a test event during the CIICD process.
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 việc một lập trình viên đang phát triển AWS Lambda function để xử lý (consume) tin nhắn từ hàng đợi Amazon SQS. Mục tiêu là tích hợp unit testing (kiểm thử đơn vị) vào quy trình CI/CD (Continuous Integration/Continuous Delivery) của function này.
✅ Unit testing ở đây nhấn mạnh việc kiểm tra logic code của Lambda một cách cô lập (isolated), không phụ thuộc vào các dịch vụ AWS thực tế như SQS thật, để đảm bảo nhanh chóng, đáng tin cậy và không tốn kém. Theo best practices AWS (cập nhật đến 2024-2026), unit test nên sử dụng test events (payload JSON mô phỏng event từ SQS) để invoke function mà không cần deploy hoặc tạo tài nguyên thật. Quy trình CI/CD thường chạy test này trong pipeline (như AWS CodeBuild, GitHub Actions) trước khi deploy production.
📘 Nguồn tham khảo chính:
- AWS Documentation: Testing Lambda functions (Unit testing phần).
- AWS Well-Architected Framework: Serverless Lens (2024 update) khuyến nghị isolated unit tests với mock events.
- AWS SAM CLI:
sam local invokehoặc AWS SDK cho local testing (không cần deploy).
✅ Đáp án đúng:
Use the aws lambda invoke command with a test event during the CIICD process.
Lý do chọn: Phương án này cho phép unit testing thực thụ bằng cách sử dụng lệnh AWS CLI aws lambda invoke với test event (JSON payload giả lập event SQS), chạy trực tiếp trong pipeline CI/CD mà không cần tạo SQS queue thật hoặc deploy đầy đủ. Điều này cô lập logic code, nhanh chóng và phù hợp best practices AWS (hỗ trợ đến 2026 với Lambda runtime mới nhất như Python 3.12/Node.js 20). Test event được tạo thủ công dựa trên schema SQS event (docs.aws.amazon.com/lambda/latest/dg/with-sqs.html). Trong CI/CD, có thể zip code và invoke qua Lambda service (sau deploy temp) hoặc SAM local cho pure unit test. Lưu ý: "CIICD" là lỗi đánh máy của "CI/CD".
🛠️ Giải thích chi tiết tất cả các phương án (dùng emoji đánh dấu đúng/sai):
-
❌ Create an AWS CloudFormation template that creates an SQS queue and deploys the Lambda function. Create a stack from the template during the CI/CD process. Invoke the deployed function. Verify the output.
Sai vì: Đây là integration testing (kiểm thử tích hợp), không phải unit testing. Nó tạo SQS queue thật và deploy Lambda qua CloudFormation stack, tốn thời gian/không gian (provisioning resources), dễ fail do quota/network, và không cô lập code (phụ thuộc AWS services). Phù hợp smoke test sau deploy, không cho CI/CD unit phase. -
❌ Create an SQS event for tests. Use a test that consumes messages from the SQS queue during the function's Cl/CD process.
Sai vì: Vẫn yêu cầu consume từ SQS queue thật trong CI/CD, dẫn đến integration test thay vì unit test. "SQS event for tests" mơ hồ nhưng imply dùng queue thực (không cô lập), tốn kém, chậm và không scalable. AWS khuyến nghị tránh real services cho unit test để tránh side effects như message loss. -
❌ Create an SQS queue for tests. Use this SQS queue in the application's unit test. Run the unit tests during the CI/CD process.
Sai vì: Tạo SQS queue test thật (dù là test env) vẫn là integration/end-to-end test, không phải unit test thuần túy. Unit test phải isolated (không hit AWS APIs thật), tránh chi phí (SQS requests ~$0.40/million) và độ trễ deploy queue. AWS docs khuyên dùng local mocks hoặc test events thay thế. -
✅ Use the aws lambda invoke command with a test event during the CIICD process.
Đúng vì: ✅ Như đã giải thích ở trên, đây là cách chuẩn cho unit testing Lambda với SQS trigger: Tạo test event JSON (e.g.,{"Records": [{"body": "test msg"}]}), invoke qua CLI/SDK trong CI/CD pipeline. Hỗ trợ local (SAM CLI) hoặc cloud (deploy dev version), nhanh (<1s/test), zero-cost cho logic test. Tích hợp dễ với CodeBuild/Jenkins.
🧩 Lời khuyên bổ sung: Trong thực tế DevOps Pro, kết hợp với pytest/motcha (Python) hoặc Jest (Node.js) để mock SQS event parsing, chạy local trước CI/CD. Sử dụng AWS SAM cho full local env: sam local invoke --event events/sqs-event.json. Điều này đảm bảo coverage >80% trước deploy! 🚀
The table usage patterns include the retrieval of multiple songs and artists in a single database operation from the webpage. The developer needs a way to retrieve this information with minimal network traffic and optimal application performance.
Which solution will meet these requirements?
- A Perform a BatchGetltem operation that returns items from the two tables. Use the list of songName/artistName keys for the songs table and the list of artistName key for the artists table.
- B Create a local secondary index (LSI) on the songs table that uses artistName as the partition key. Perform a query operation for each artistName on the songs table that filters by the list of songName. Perform a query operation for each artistName on the artists table.
- C Perform a BatchGetitem operation on the songs table that uses the songName/artistName keys. Perform a BatchGetltem operation on the artists table that uses artistName as the key.
- D Perform a Scan operation on each table that filters by the list of songName/artistName for the songs table and the list of artistName in the artists table.
Xem giải thích
🧩 Phân tích nội dung câu hỏi
Câu hỏi xoay quanh một ứng dụng web sử dụng Amazon DynamoDB làm kho dữ liệu, với hai bảng:
- Bảng artists: Partition key (PK) là artistName.
- Bảng songs: Partition key là songName, Sort key (SK) là artistName (tức là composite primary key).
Mô hình sử dụng bao gồm việc lấy nhiều bài hát (songs) và nghệ sĩ (artists) trong một hoạt động cơ sở dữ liệu duy nhất từ trang web. Nhà phát triển cần giải pháp giảm thiểu lưu lượng mạng (minimal network traffic) và tối ưu hiệu suất ứng dụng (optimal application performance).
🛠️ Yêu cầu chính: Sử dụng một hoạt động (operation) duy nhất để truy xuất dữ liệu từ cả hai bảng, tránh nhiều request riêng lẻ gây tốn bandwidth và latency cao. DynamoDB hỗ trợ các operation như Query, Scan, GetItem, BatchGetItem – cần chọn cái phù hợp nhất với multi-table và multi-items.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Perform a BatchGetltem operation that returns items from the two tables. Use the list of songName/artistName keys for the songs table and the list of artistName key for the artists table.
Lý do:
- BatchGetItem là operation lý tưởng vì nó cho phép lấy **tối đa 100 items từ một hoặc nhiều bảng DynamoDB trong một request duy nhất (single API call).
- Ở đây, sử dụng danh sách keys đầy đủ (songName/artistName cho songs, artistName cho artists) để lấy chính xác items cần thiết.
- ✅ Lợi ích: Giảm thiểu network traffic (chỉ 1 request thay vì nhiều), tối ưu performance (low latency, consistent read capacity units - RCU), phù hợp với pattern "retrieval of multiple songs and artists in a single database operation".
- Theo tài liệu AWS mới nhất (2026), BatchGetItem hỗ trợ cross-table và unprocessed items handling tự động.
📘 Tài liệu tham khảo:
📋 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 bằng tiếng Anh. Mỗi phương án được đánh giá đúng/sai với lý do cụ thể:
-
Perform a BatchGetltem operation that returns items from the two tables. Use the list of songName/artistName keys for the songs table and the list of artistName key for the artists table.
✅ Đúng: Như đã giải thích ở trên, đây là giải pháp tối ưu nhất với single operation multi-table, keys chính xác khớp primary key của từng bảng, giảm thiểu traffic và latency. Hoàn hảo cho requirement! -
Create a local secondary index (LSI) on the songs table that uses artistName as the partition key. Perform a query operation for each artistName on the songs table that filters by the list of songName. Perform a query operation for each artistName on the artists table.
❌ Sai:- LSI không thể thay đổi partition key (phải chia sẻ PK partition với base table). Bảng songs có PK là songName, nên LSI chỉ có thể dùng cùng partition key songName và sort key khác. Không thể dùng artistName làm partition key mới.
- Cần nhiều Query operations (cho mỗi artistName), cộng thêm Query trên artists → nhiều request, tăng network traffic và RCU/WCU cao. Filter by songName trong Query cũng kém hiệu quả (chỉ filter sau khi đọc partition).
- Không đáp ứng "single database operation".
-
Perform a BatchGetitem operation on the songs table that uses the songName/artistName keys. Perform a BatchGetltem operation on the artists table that uses artistName as the key.
❌ Sai:- Đây là hai BatchGetItem riêng biệt (một cho songs, một cho artists) → hai API calls, không phải "single database operation". Mặc dù BatchGetItem tốt cho multi-items/table, nhưng vẫn gây double network round-trip, tăng latency và traffic.
- Không tận dụng khả năng multi-table của BatchGetItem trong một call duy nhất.
-
Perform a Scan operation on each table that filters by the list of songName/artistName for the songs table and the list of artistName in the artists table.
❌ Sai:- Scan quét toàn bộ bảng (full table scan), sau đó filter → rất kém hiệu suất, tốn RCU cao (1 RCU/1KB scanned), không scalable với dữ liệu lớn.
- Cần hai Scan operations → tăng traffic gấp bội, latency cao, không optimal. Filter chỉ là post-scan, không dùng index/keys hiệu quả. AWS khuyến cáo tránh Scan cho production queries.
🧩 Tóm tắt: BatchGetItem là "vũ khí bí mật" của DynamoDB cho batch retrieval cross-table, giúp đạt minimal traffic + optimal perf như yêu cầu! Nếu implement, nhớ handle unprocessed keys nếu vượt 100 items. 🚀