Ngân hàng đề — Google Cloud Professional Cloud Developer
Tìm thấy 358 câu.
- A Create two jobs: one that checks whether the container can connect to the database, and another that runs the shutdown script if the Pod is failing.
- B Create the Deployment with a livenessProbe for the container that will fail if the container can't connect to the database. Configure a Prestop lifecycle handler that runs the shutdown script if the container is failing.
- C Create the Deployment with a PostStart lifecycle handler that checks the service availability. Configure a PreStop lifecycle handler that runs the shutdown script if the container is failing.
- D Create the Deployment with an initContainer that checks the service availability. Configure a Prestop lifecycle handler that runs the shutdown script if the Pod is failing.
Xem giải thích
🧩 Phân tích chi tiết nội dung câu hỏi
Câu hỏi yêu cầu cấu hình một Deployment trên Google Kubernetes Engine (GKE) để bao gồm một cơ chế kiểm tra (check) xác nhận rằng các container có thể kết nối thành công đến database. Nếu Pod (chứa container) không thể kết nối, một script trong container phải được chạy để thực hiện graceful shutdown (tắt một cách an toàn, không đột ngột).
🛠️ Yêu cầu chính:
- Kiểm tra kết nối DB phải liên tục và tự động (không phải một lần).
- Nếu kiểm tra thất bại → Chạy script shutdown trước khi Pod bị terminate.
- Sử dụng các tính năng của Kubernetes/GKE như probes (liveness/readiness/startup) hoặc lifecycle hooks (PostStart/PreStop), hoặc initContainers/Jobs.
📘 Kiến thức nền tảng (cập nhật Kubernetes 1.30+ trên GKE Standard/Autopilot đến 2026):
- LivenessProbe: Kiểm tra sức khỏe container định kỳ. Nếu fail → Kubernetes terminate container và restart (nếu restartPolicy cho phép).
- PreStop hook: Exec script trước khi terminate container, lý tưởng cho graceful shutdown (ví dụ: đóng kết nối DB sạch sẽ).
- Các cơ chế khác như initContainer (chạy một lần trước main container), PostStart (chạy sau start), Jobs (chạy độc lập, không gắn với Deployment Pod).
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Create the Deployment with a livenessProbe for the container that will fail if the container can't connect to the database. Configure a Prestop lifecycle handler that runs the shutdown script if the container is failing.
Lý do 🏆:
- LivenessProbe kiểm tra liên tục kết nối DB (exec command như
nc -z db-host 5432hoặc HTTP check). Nếu fail → Kubernetes tự động terminate container. - PreStop hook chạy ngay trước terminate, kích hoạt script graceful shutdown (ví dụ: flush logs, đóng connections).
- Kết hợp hoàn hảo: Probe phát hiện vấn đề → Hook xử lý shutdown an toàn. Không restart vô tận vì sau shutdown Pod có thể được replace bởi Deployment.
- Phù hợp GKE best practices (Kubernetes docs khuyến nghị cho DB dependency checks).
📋 Giải thích tất cả các phương án (đúng/sai)
-
❌ [SAI] Create two jobs: one that checks whether the container can connect to the database, and another that runs the shutdown script if the Pod is failing.
Phân tích sai: Jobs chạy độc lập, một lần (hoặc cron), không gắn với lifecycle của Deployment Pod. Không thể kiểm tra liên tục cho container đang chạy, và không trigger shutdown graceful cho Pod cụ thể. Jobs phù hợp batch tasks, không phải health check Pod. Sẽ tạo overhead không cần thiết và không đồng bộ. -
✅ [ĐÚNG] Create the Deployment with a livenessProbe for the container that will fail if the container can't connect to the database. Configure a Prestop lifecycle handler that runs the shutdown script if the container is failing.
Phân tích đúng: Như lý do trên. LivenessProbe fail → Trigger terminate → PreStop chạy script. Hoàn thành yêu cầu "verifies... nếu failing thì shutdown". Best practice cho ongoing checks trong GKE. -
❌ [SAI] Create the Deployment with a PostStart lifecycle handler that checks the service availability. Configure a PreStop lifecycle handler that runs the shutdown script if the container is failing.
Phân tích sai: PostStart chạy một lần ngay sau start container, chỉ check initial availability (không liên tục như yêu cầu "verifies that the containers can connect" ongoing). Không detect failing sau đó. PreStop chỉ chạy khi terminate, nhưng thiếu cơ chế trigger liên tục → Không khớp yêu cầu. -
❌ [SAI] Create the Deployment with an initContainer that checks the service availability. Configure a Prestop lifecycle handler that runs the shutdown script if the Pod is failing.
Phân tích sai: initContainer chạy một lần trước main container, chỉ check startup (nếu fail → Pod fail-fast). Không kiểm tra liên tục khi main container chạy (DB có thể fail sau). PreStop chạy khi terminate nhưng thiếu ongoing verification → Không detect failing runtime.
🔗 Tài liệu tham khảo (cập nhật 2026)
- Kubernetes Docs: Configure Liveness, Readiness and Startup Probes & Attach Handlers to Container Lifecycle Events (Kubernetes 1.30+).
- GKE Docs: Probes and Lifecycle Hooks & Deployment Best Practices.
- AWS tương đương (EKS): Tương tự, nhưng câu hỏi về GKE (không AWS-specific). Xem EKS: Pod Lifecycle.
🧠 Mẹo học: Ưu tiên probes + hooks cho health checks graceful trong Production GKE! 🚀
•https://yourcompany.com/students
•https://yourcompany.com/teachers
•https://yourcompany.com/classes
You need to configure each API URL path to invoke a different function in your code. What should you do?
- A Create one Cloud Function as a backend service exposed using an HTTPS load balancer.
- B Create three Cloud Functions exposed directly.
- C Create one Cloud Function exposed directly.
- D Create three Cloud Functions as three backend services exposed using an HTTPS load balancer.
Xem giải thích
🧩 Phân tích chi tiết câu hỏi
📖 Nội dung câu hỏi:
Câu hỏi yêu cầu triển khai một API mới với ba đường dẫn URL khác nhau trên cùng một domain (https://yourcompany.com):
/students/teachers/classes
Mỗi đường dẫn URL này phải kích hoạt (invoke) một hàm (function) khác nhau trong mã nguồn. Vấn đề cốt lõi là cần cấu hình routing dựa trên đường dẫn URL để phân luồng traffic đến các hàm riêng biệt, đồng thời giữ nguyên domain chung. Đây là tình huống điển hình trong Google Cloud Platform (GCP), sử dụng Cloud Functions (serverless functions) và HTTPS Load Balancer để xử lý routing path-based.
🎯 Mục tiêu chính:
- Đảm bảo tính linh hoạt, scalability cao (serverless).
- Hỗ trợ custom domain và path-based routing mà không cần quản lý server.
(Lưu ý: Mặc dù người dùng đề cập "liên quan đến AWS", nhưng terminology như "Cloud Functions" và "HTTPS load balancer" là của GCP, không phải AWS Lambda/API Gateway. Tôi phân tích dựa trên GCP theo kiến thức mới nhất đến 2026, với Cloud Functions Gen 2 hỗ trợ tích hợp tốt hơn với Load Balancer qua Serverless NEG - Network Endpoint Group).
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Create three Cloud Functions as three backend services exposed using an HTTPS load balancer.
🛠️ Lý do chi tiết:
- Tạo ba Cloud Functions riêng biệt (một cho
/students, một cho/teachers, một cho/classes). - Mỗi Cloud Function được expose qua Serverless NEG và gắn vào một backend service riêng.
- HTTPS Load Balancer (Global External HTTP(S) LB) xử lý path-based routing: Phân luồng traffic dựa trên URL path đến backend service tương ứng.
- Ưu điểm: Scalable tự động (serverless), hỗ trợ custom domain, SSL termination, và tích hợp Cloud Armor/WAF. Đây là best practice cho multi-function APIs trên GCP (cập nhật 2026: Cloud Functions 2nd Gen với Eventarc và VPC connector cải tiến).
- Nguồn tham khảo:
- GCP Docs: Route traffic with load balancers to Cloud Functions (tương tự cho Cloud Functions).
- Cloud Functions with HTTPS LB Backend Services.
📋 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:
-
❌ [SAI] Create one Cloud Function as a backend service exposed using an HTTPS load balancer.
Chỉ tạo một Cloud Function duy nhất làm backend service. Load Balancer không thể route path-based đến các hàm khác nhau trong cùng một function – toàn bộ traffic sẽ đi đến function đó, không phân biệt/students,/teachers, hay/classes. Không đáp ứng yêu cầu invoke different functions. -
❌ [SAI] Create three Cloud Functions exposed directly.
Tạo ba Cloud Functions và expose trực tiếp (qua trigger HTTPS). Mỗi function sẽ có URL riêng biệt (ví dụ:https://region-project.cloudfunctions.net/students), không thể dùng chung domainyourcompany.comvới path routing. Không hỗ trợ custom domain thống nhất và routing path-based. -
❌ [SAI] Create one Cloud Function exposed directly.
Chỉ một function expose trực tiếp: Không có routing, tất cả paths đều gọi cùng một function. Không scalable cho multi-path và không dùng custom domain dễ dàng. -
✅ [ĐÚNG] Create three Cloud Functions as three backend services exposed using an HTTPS load balancer.
Như đã giải thích ở trên: Ba backend services (mỗi gắn một Cloud Function qua Serverless NEG), HTTPS LB route theo path. Hoàn hảo cho yêu cầu! 🏆
💡 Lời khuyên triển khai: Sử dụng URL Map trong Load Balancer để map path (e.g., /students/* → backend_students). Test với gcloud CLI và monitor qua Cloud Logging/Metrics (cập nhật 2026: Tích hợp AI Routing với Vertex AI).
- A Use the gcloud CLI to call Container Analysis to scan new container images. Review the vulnerability results before each deployment.
- B Enable Container Analysis, and upload new container images to Artifact Registry. Review the vulnerability results before each deployment.
- C Enable Container Analysis, and upload new container images to Artifact Registry. Review the critical vulnerability results before each deployment.
- D Use the Container Analysis REST API to call Container Analysis to scan new container images. Review the vulnerability results before each deployment.
Xem giải thích
🧩 Phân tích chi tiết câu hỏi
✅ Nội dung câu hỏi:
Câu hỏi yêu cầu triển khai ứng dụng microservices lên Google Kubernetes Engine (GKE). Ứng dụng nhận cập nhật hàng ngày, dự kiến chạy một số lượng lớn container riêng biệt trên hệ điều hành Linux. Yêu cầu chính là được cảnh báo về các lỗ hổng bảo mật OS đã biết trong các container mới, đồng thời tuân thủ best practices được Google khuyến nghị. Điều này nhấn mạnh vào việc quét lỗ hổng tự động, tích hợp liền mạch với quy trình CI/CD, và kiểm tra trước khi triển khai để đảm bảo an toàn cho môi trường GKE.
🛠️ Bối cảnh kỹ thuật (cập nhật đến 2026):
- Container Analysis là dịch vụ của Google Cloud dùng để quét lỗ hổng (vulnerabilities) trong container images, bao gồm OS packages trên Linux (như CVE).
- Best practice: Kích hoạt Container Analysis trên Artifact Registry (thay thế Container Registry từ 2023), cho phép quét tự động khi upload image. Không cần gọi API/CLI thủ công.
- Review tất cả vulnerability results (không chỉ critical) trước deploy để tránh rủi ro. GKE khuyến khích tích hợp với Artifact Registry cho scanning binary authorization và vulnerability scanning.
📘 Tài liệu tham khảo:
- Container Analysis Overview (Google Cloud Docs, cập nhật 2025).
- Best practices for GKE security (khuyến nghị Artifact Registry + Container Analysis).
- Artifact Registry Vulnerability Scanning (tích hợp auto-scan từ 2023+).
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Enable Container Analysis, and upload new container images to Artifact Registry. Review the vulnerability results before each deployment.
Lý do:
🟢 Đây là best practice chính thức của Google cho GKE. Kích hoạt Container Analysis trên Artifact Registry sẽ tự động quét tất cả vulnerabilities (bao gồm OS Linux) ngay khi upload image mới. Quy trình: Upload → Scan auto → Review results (toàn bộ, không chỉ critical) → Deploy an toàn. Phù hợp với cập nhật hàng ngày và số lượng lớn container, tránh thủ công CLI/API. Đảm bảo alerting qua notifications nếu cần.
❌ Phân tích tất cả các phương án (đúng/sai)
-
Use the gcloud CLI to call Container Analysis to scan new container images. Review the vulnerability results before each deployment.
❌ Sai: Phương án này yêu cầu gọi gcloud CLI thủ công mỗi lần scan, không phải best practice. Container Analysis nên tự động qua Artifact Registry, tránh tốn công sức cho daily updates và large-scale containers. CLI chỉ dùng cho troubleshooting, không scalable. -
Enable Container Analysis, and upload new container images to Artifact Registry. Review the vulnerability results before each deployment.
✅ Đúng: Như đã giải thích ở trên. Tích hợp hoàn hảo với GKE workflow: Enable scanning → Upload Artifact Registry → Auto-scan OS vulnerabilities → Review full results trước deploy. Google khuyến nghị 100% cho production. -
Enable Container Analysis, and upload new container images to Artifact Registry. Review the critical vulnerability results before each deployment.
❌ Sai: Gần đúng nhưng thiếu sót: Chỉ review "critical" bỏ qua medium/low vulnerabilities, vi phạm best practice. Google yêu cầu review tất cả results (qua dashboard hoặc API) để đảm bảo zero-risk OS exploits trên Linux containers. -
Use the Container Analysis REST API to call Container Analysis to scan new container images. Review the vulnerability results before each deployment.
❌ Sai: Tương tự phương án đầu, dùng REST API thủ công không hiệu quả cho daily/large deployments. Best practice là auto-scan qua Artifact Registry, không cần gọi API mỗi lần. API chỉ cho custom integrations nâng cao.
🛡️ Lời khuyên bổ sung: Tích hợp Binary Authorization với Container Threat Detection (GKE Enterprise, 2025+) để block auto images có vulnerabilities. Test bằng gcloud artifacts docker images scan cho POC!
- A Create a Google service account with BigQuery access. Add the JSON key to Secret Manager, and use the Go client library to access the JSON key.
- B Create a Google service account with BigQuery access. Add the Google service account JSON key as a Kubernetes secret, and configure the application to use this secret.
- C Create a Google service account with BigQuery access. Add the Google service account JSON key to Secret Manager, and use an init container to access the secret for the application to use.
- D Create a Google service account and a Kubernetes service account. Configure Workload Identity on the GKE cluster, and reference the Kubernetes service account on the application Deployment.
Xem giải thích
🧩 Phân tích nội dung câu hỏi
Câu hỏi mô tả tình huống thực tế của một lập trình viên (developer) tại tổ chức lớn, đang phát triển ứng dụng viết bằng ngôn ngữ Go (Golang) chạy trên cụm Google Kubernetes Engine (GKE) ở môi trường production. Ứng dụng cần thêm tính năng mới yêu cầu truy cập vào dịch vụ BigQuery (dịch vụ kho dữ liệu phân tích lớn của Google Cloud). Nhiệm vụ là cấp quyền truy cập BigQuery cho cụm GKE theo best practices được Google khuyến nghị, nhằm đảm bảo an toàn, tuân thủ nguyên tắc least privilege (quyền tối thiểu cần thiết), tránh rủi ro lộ khóa bí mật, và dễ quản lý ở quy mô lớn.
🛠️ Mục tiêu chính: Không sử dụng service account key files (JSON keys) vì chúng dễ bị lộ, khó xoay vòng, và không an toàn trong môi trường containerized như GKE. Thay vào đó, ưu tiên cơ chế Workload Identity – phương pháp hiện đại nhất (cập nhật đến 2024-2026) để pods trong GKE có thể impersonate Google Service Account (GSA) mà không cần lưu trữ credentials tĩnh.
📘 Tài liệu tham khảo:
✅ Đáp án đúng
Create a Google service account and a Kubernetes service account. Configure Workload Identity on the GKE cluster, and reference the Kubernetes service account on the application Deployment.
Lý do lựa chọn: Đây là best practice chính thức của Google cho GKE (từ phiên bản GKE 1.13+ và được khuyến nghị mạnh mẽ đến 2026). Workload Identity liên kết Kubernetes Service Account (KSA) với Google Service Account (GSA), cho phép pod tự động nhận token OIDC để truy cập GCP services như BigQuery mà không cần JSON keys.
- ✅ An toàn cao: Không lưu trữ secrets tĩnh, tự động xoay token.
- ✅ Dễ quản lý: Gán quyền IAM cho GSA (ví dụ:
roles/bigquery.dataEditor), annotate KSA vớiiam.gke.io/gcp-service-account=gsa@project.iam.gserviceaccount.com. - ✅ Hỗ trợ Go client library (như
cloud.google.com/go/bigquery) tự detect credentials từ metadata server. Quy trình: Tạo GSA → Tạo KSA → Enable Workload Identity trên cluster/nodepool → Annotate KSA → Reference KSA trong Deployment spec.
❌ Giải thí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. Các phương án sai đều vi phạm best practices vì sử dụng JSON keys (service account key files) – rủi ro cao về bảo mật (dễ leak qua logs, images, hoặc misconfig), khó audit, và không scalable ở production.
-
[SAI] Create a Google service account with BigQuery access. Add the JSON key to Secret Manager, and use the Go client library to access the JSON key.
❌ Sai vì: Secret Manager chỉ lưu trữ an toàn key, nhưng vẫn phải tải JSON key vào runtime (qua Go client), dẫn đến rủi ro lộ key trong memory hoặc logs. Không phải best practice; Google khuyến cáo tránh keys hoàn toàn, ưu tiên Workload Identity. Phức tạp không cần thiết cho GKE. -
[SAI] Create a Google service account with BigQuery access. Add the Google service account JSON key as a Kubernetes secret, and configure the application to use this secret.
❌ Sai vì: Kubernetes Secrets lưu JSON key dưới dạng base64 (vẫn dễ đọc), dễ bị pod khác truy cập hoặc leak qua volume mounts. Vi phạm nguyên tắc "no keys in cluster". Google cấm sử dụng cách này ở production từ 2020+. -
[SAI] Create a Google service account with BigQuery access. Add the Google service account JSON key to Secret Manager, and use an init container to access the secret for the application to use.
❌ Sai vì: Init container tăng độ phức tạp, vẫn phải mount/pull JSON key vào app container, rủi ro tương tự hai cách trên (leak secrets). Không giải quyết gốc rễ vấn đề bảo mật; Workload Identity đơn giản hơn và an toàn hơn.
🛡️ Tóm tắt lợi ích Workload Identity (so với các cách sai): Giảm bề mặt tấn công 100%, tích hợp native với IAM, hỗ trợ fine-grained permissions, và audit qua Cloud Logging/Audit Logs. Áp dụng ngay cho app Go bằng cách set GOOGLE_APPLICATION_CREDENTIALS không cần thiết!
- A Create a user-managed service account with a custom Identity and Access Management (IAM) role.
- B Create a user-managed service account with the Storage Admin Identity and Access Management (IAM) role.
- C Create a user-managed service account with the Project Editor Identity and Access Management (IAM) role.
- D Use the default service account linked to the Cloud Run revision in production.
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 cấp quyền truy cập cho một ứng dụng Python đang chạy trên Cloud Run (dịch vụ serverless container trên Google Cloud) để đọc/ghi dữ liệu vào một Cloud Storage bucket nằm trong cùng project. Yêu cầu chính là tuân thủ nguyên tắc least privilege (quyền hạn tối thiểu), nghĩa là chỉ cấp những quyền cần thiết nhất, tránh cấp quyền rộng để giảm rủi ro bảo mật.
Ứng dụng cần quyền cụ thể như storage.objects.create, storage.objects.get, storage.objects.update, storage.objects.delete (hoặc tương đương trong role roles/storage.objectAdmin) cho bucket đó. Đây là tình huống phổ biến trong Google Cloud, nơi service account được sử dụng để Cloud Run xác thực với các dịch vụ khác mà không cần key thủ công.
✅ Đáp án đúng: Create a user-managed service account with a custom Identity and Access Management (IAM) role.
Lý do chọn: Phương án này tuân thủ hoàn hảo nguyên tắc least privilege. Bạn tạo một user-managed service account (không dùng default) và gắn custom IAM role chỉ chứa các quyền tối thiểu cần thiết cho Cloud Storage (ví dụ: chỉ read/write objects trong bucket cụ thể). Sau đó, gán service account này cho Cloud Run service qua lệnh gcloud run services update --service-account. Điều này tránh cấp quyền thừa, dễ audit và quản lý. Theo docs Google Cloud mới nhất (2024-2026), custom role hỗ trợ granular permissions tốt hơn predefined roles.
📘 Nguồn tham khảo: Google Cloud Run IAM docs, Custom Roles guide.
🛠️ 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á dựa trên least privilege và thực tiễn Google Cloud mới nhất:
-
Create a user-managed service account with a custom Identity and Access Management (IAM) role.
✅ Đúng. Như đã giải thích ở trên, đây là cách tối ưu: user-managed SA cho phép kiểm soát đầy đủ, custom role chỉ cấp quyền cụ thể (ví dụ:storage.buckets.get+ object permissions), giảm bề mặt tấn công. Không vi phạm least privilege. -
Create a user-managed service account with the Storage Admin Identity and Access Management (IAM) role.
❌ Sai. RoleStorage Admin(roles/storage.admin) cấp quyền quá rộng: quản lý toàn bộ buckets trong project (tạo/xóa bucket, ACL toàn bộ). Ứng dụng chỉ cần read/write objects, không cần admin toàn bộ storage → vi phạm least privilege. Nên dùng role hẹp hơn nhưStorage Object Admin. -
Create a user-managed service account with the Project Editor Identity and Access Management (IAM) role.
❌ Sai. RoleProject Editor(roles/editor) cấp quyền rất rộng: chỉnh sửa hầu hết tài nguyên trong project (Compute Engine, Cloud Storage, BigQuery, v.v.). Đây là quyền "siêu user" không cần thiết cho chỉ read/write bucket, dễ dẫn đến privilege escalation. Google khuyến cáo tránh Editor từ 2023+. -
Use the default service account linked to the Cloud Run revision in production.
❌ Sai. Default service account của Cloud Run (thường làPROJECT_NUMBER-compute@developer.gserviceaccount.com) kế thừa quyền từ Compute Engine default SA, có roleEditorhoặc tương đương → quyền rộng khắp project. Không kiểm soát được, vi phạm least privilege nghiêm trọng. Google khuyên luôn dùng user-managed SA cho production (theo best practices 2024-2026).
🛡️ Lời khuyên thực hành: Sử dụng gcloud iam roles create để tạo custom role, sau đó attach vào SA và deploy Cloud Run với --service-account. Kiểm tra quyền bằng IAM Policy Analyzer để đảm bảo an toàn!
- A Configure Cloud Build to deploy the Cloud Function. If the code passes the tests, a deployment approval is sent to you.
- B Configure Cloud Build to deploy the Cloud Function, using the specific service account as the build agent. Run the unit tests after successful deployment.
- C Configure Cloud Build to run the unit tests. If the code passes the tests, the developer deploys the Cloud Function.
- D Configure Cloud Build to run the unit tests, using the specific service account as the build agent. If the code passes the tests, Cloud Build deploys the Cloud Function.
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 quy trình unit testing cho code Cloud Functions trong Google Cloud Platform (GCP). Đội ngũ đang phát triển unit tests cho code lưu trữ trong Cloud Source Repositories. Bạn chịu trách nhiệm triển khai tests, và chỉ một service account cụ thể mới có quyền deploy code lên Cloud Functions. Mục tiêu chính: Đảm bảo code KHÔNG THỂ deploy nếu chưa pass unit tests (ngăn chặn deploy tự ý mà không kiểm tra).
🛠️ Các yếu tố then chốt:
- Sử dụng Cloud Build để tự động hóa pipeline CI/CD.
- Trigger build từ repository changes.
- Chạy tests TRƯỚC deploy.
- Chỉ deploy khi tests pass, sử dụng service account duy nhất có quyền làm build agent để tránh bypass.
📘 Kiến thức cập nhật (GCP 2026): Cloud Build hỗ trợ triggers từ Cloud Source Repositories, chạy steps song song/tuần tự, và deploy Cloud Functions qua gcloud CLI hoặc API với service account (theo docs GCP mới nhất, Cloud Build v2 với Gen2 builders tối ưu hóa tốc độ).
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Configure Cloud Build to run the unit tests, using the specific service account as the build agent. If the code passes the tests, Cloud Build deploys the Cloud Function.
Lý do:
- 🛡️ Đảm bảo an toàn: Cloud Build trigger tự động từ repo changes → chạy unit tests trước → chỉ deploy nếu pass (fail thì dừng pipeline).
- 🔑 Quyền hạn chặt chẽ: Sử dụng specific service account làm build agent (qua
cloudbuild.yamlvới--service-account), đảm bảo chỉ build này mới deploy được, developer không bypass. - 🚀 Tự động hóa đầy đủ: Tests → Deploy liền mạch trong cùng pipeline, không cần can thiệp thủ công.
- 📈 Best practice GCP: Theo CI/CD pipeline tiêu chuẩn (Cloud Build + Cloud Functions), ngăn "deploy mà không test".
🧪 Giải thí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. Tôi giữ nguyên văn bản gốc tiếng Anh của phương án, chỉ giải thích bằng tiếng Việt với emoji đánh dấu đúng/sai:
-
❌ [SAI] Configure Cloud Build to deploy the Cloud Function. If the code passes the tests, a deployment approval is sent to you.
Lý do sai: Deploy trước tests? Không khớp yêu cầu "chạy tests trước deploy". Gửi approval thủ công cho bạn → dễ bypass (developer deploy trực tiếp), không tự động và không dùng service account unique. Rủi ro cao, vi phạm nguyên tắc "cannot be deployed without passing tests". -
❌ [SAI] Configure Cloud Build to deploy the Cloud Function, using the specific service account as the build agent. Run the unit tests after successful deployment.
Lý do sai: Deploy TRƯỚC tests (post-deployment testing) → code fail tests vẫn đã deploy lên production, gây lỗi runtime. Không đảm bảo "không deploy nếu chưa pass tests". Dù dùng service account đúng, thứ tự sai hoàn toàn. -
❌ [SAI] Configure Cloud Build to run the unit tests. If the code passes the tests, the developer deploys the Cloud Function.
Lý do sai: Tests chạy đúng thứ tự, nhưng developer tự deploy sau → có thể bỏ qua build (deploy thủ công qua console/gcloud), không dùng service account unique → ai cũng deploy được nếu có quyền. Không "ensure cannot be deployed without tests". -
✅ [ĐÚNG] Configure Cloud Build to run the unit tests, using the specific service account as the build agent. If the code passes the tests, Cloud Build deploys the Cloud Function.
Lý do đúng: Hoàn hảo! Tests trước deploy trong pipeline, dùng service account → chỉ build pass mới deploy, không bypass. Tự động, an toàn 100%.
📚 Tài liệu tham khảo (GCP cập nhật 2026)
- Cloud Build Triggers: docs.cloud.google.com/build/docs/automating-builds/build-triggers – Trigger từ Cloud Source Repositories.
- Deploy Cloud Functions via Cloud Build: cloud.google.com/functions/docs/deploy – Sử dụng service account trong
cloudbuild.yaml. - CI/CD Best Practices: cloud.google.com/architecture/ci-cd – Pipeline tests-before-deploy.
🧑💻 Mẹo thực hành: Tạocloudbuild.yamlvới steps:npm test→gcloud functions deploynếu exit 0. Assign service account qua IAM:roles/cloudbuild.builds.builder.
- A Deploy the Pub/Sub and Cloud Run emulators on your local machine. Deploy the application locally, and change the logging level in the application to DEBUG or INFO. Write mock messages to topic A, and then analyze the logs.
- B Use the gcloud CLI to write mock messages to topic A. Change the logging level in the application to DEBUG or INFO, and then analyze the logs.
- C Deploy the Pub/Sub emulator on your local machine. Point the production application to your local Pub/Sub topics. Write mock messages to topic A, and then analyze the logs.
- D Use the Google Cloud console to write mock messages to topic A. Change the logging level in the application to DEBUG or INFO, and then analyze the logs.
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ình huống thực tế trong Google Cloud Platform (GCP): Ứng dụng chạy trên Cloud Run (một dịch vụ serverless để deploy container) đang gặp spike lỗi (tăng đột biến lỗi) trong môi trường production. Ứng dụng này đọc tin nhắn từ Pub/Sub topic A, xử lý chúng, rồi ghi vào topic B. Nhiệm vụ là thực hiện test để tìm nguyên nhân lỗi, sử dụng mock messages (tin nhắn giả lập).
Mục tiêu chính: Debug an toàn, không ảnh hưởng production, bằng cách simulate môi trường local để kiểm tra logs với logging level DEBUG/INFO. Đây là best practice trong phát triển GCP, tận dụng emulators để mimic dịch vụ cloud mà không tốn chi phí hoặc rủi ro prod (theo docs GCP cập nhật 2025-2026).
📘 Tài liệu tham khảo:
- Pub/Sub Emulator (cập nhật 2025).
- Cloud Run Local Development & Cloud Run Emulator via gcloud beta (hỗ trợ emulator đầy đủ từ 2024+).
- Debugging Cloud Run (best practices 2026).
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Deploy the Pub/Sub and Cloud Run emulators on your local machine. Deploy the application locally, and change the logging level in the application to DEBUG or INFO. Write mock messages to topic A, and then analyze the logs.
Lý do:
- 🛠️ Phương án này an toàn 100%, isolate hoàn toàn khỏi production bằng cách dùng emulators local (Pub/Sub emulator qua
gcloud beta emulators pubsub start, Cloud Run emulator quagcloud beta run deploy --localhoặc tools như Skaffold/Dev Containers). - Cho phép deploy app local, publish mock messages vào topic A emulator, xử lý và kiểm tra logs DEBUG/INFO để pinpoint lỗi (ví dụ: processing logic, serialization).
- Best practice GCP 2026: Giảm latency test, zero cost, replicate chính xác flow Pub/Sub → Cloud Run → Pub/Sub mà không rủi ro spike lỗi prod.
❌ Giải thích tất cả các phương án (đúng/sai)
-
✅ Đúng: Deploy the Pub/Sub and Cloud Run emulators on your local machine. Deploy the application locally, and change the logging level in the application to DEBUG or INFO. Write mock messages to topic A, and then analyze the logs.
🟢 Lý do đúng: Như trên, full local emulation đảm bảo reproducible testing mà không touch prod. Logs chi tiết giúp trace lỗi (e.g., dead-letter queue issues). Hỗ trợ multi-region Pub/Sub emulation từ 2025. -
❌ Sai: Use the gcloud CLI to write mock messages to topic A. Change the logging level in the application to DEBUG or INFO, and then analyze the logs.
🔴 Lý do sai:gcloud pubsub topics publishsẽ ghi trực tiếp vào topic A production, gây spike thêm messages thật, làm tình hình tệ hơn (có thể trigger autoscaling Cloud Run, tốn chi phí, ảnh hưởng user thật). Không isolate test! -
❌ Sai: Deploy the Pub/Sub emulator on your local machine. Point the production application to your local Pub/Sub topics. Write mock messages to topic A, and then analyze the logs.
🔴 Lý do sai: Point production app đến local emulator là rủi ro cao: Cần thay env vars/IAM (e.g.,PUBSUB_EMULATOR_HOST=localhost:8085), nhưng prod Cloud Run không restart dễ dàng, có thể downtime hoặc leak data. Không feasible cho prod (GCP docs cấm khuyến khích hybrid prod-local). -
❌ Sai: Use the Google Cloud console to write mock messages to topic A. Change the logging level in the application to DEBUG or INFO, and then analyze the logs.
🔴 Lý do sai: Console (Pub/Sub → Topics → Publish message) ghi thẳng vào prod topic A, tương tự CLI, gây pollution prod (spike messages thật, trigger errors mới). Chỉ phù hợp quick test nhỏ, không scale cho debugging spike lớn.
🏆 Kết luận & Tips
Phương án đúng nhấn mạnh local-first development – core principle GCP 2026 với Cloud Run + Pub/Sub emulators. Để thực hiện:
gcloud beta emulators pubsub start.- Set
PUBSUB_EMULATOR_HOST&CLOUD_RUN_LOCAL=true. - Deploy local & test!
Nếu cần code sample, tham khảo GCP Samples Repo. 🚀
-
A
1. When a user arrives at your application, prompt them for their Google username and password.
2. Store an SHA password hash in your application's database along with the user's username.
3. The application authenticates to the Google Cloud API using HTTPs requests with the user's username and password hash in the Authorization request header. -
B
1. When a user arrives at your application, prompt them for their Google username and password.
2. Forward the user's username and password in an HTTPS request to the Google Cloud authorization server, and request an access token.
3. The Google server validates the user's credentials and returns an access token to the application.
4. The application uses the access token to call the Google Cloud API. -
C
1. When a user arrives at your application, route them to a Google Cloud consent screen with a list of requested permissions that prompts the user to sign in with SSO to their Google Account.
2. After the user signs in and provides consent, your application receives an authorization code from a Google server.
3. The Google server returns the authorization code to the user, which is stored in the browser's cookies.
4. The user authenticates to the Google Cloud API using the authorization code in the cookie. -
D
1. When a user arrives at your application, route them to a Google Cloud consent screen with a list of requested permissions that prompts the user to sign in with SSO to their Google Account.
2. After the user signs in and provides consent, your application receives an authorization code from a Google server.
3. The application requests a Google Server to exchange the authorization code with an access token.
4. The Google server responds with the access token that is used by the application to call the Google Cloud API.
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 triển khai quy trình xác thực (authentication) an toàn cho một ứng dụng web server Java, cho phép người dùng ủy quyền (authorize) ứng dụng truy cập các dịch vụ Google Cloud qua Google Cloud API thay mặt họ. Mục tiêu là sử dụng danh tính Google Cloud của người dùng (Google Account) một cách bảo mật, tuân thủ các tiêu chuẩn OAuth 2.0.
📌 Yêu cầu chính:
- Ứng dụng phải xử lý luồng xác thực mà không yêu cầu người dùng nhập trực tiếp username/password (để tránh rủi ro bảo mật như lưu trữ mật khẩu).
- Sử dụng SSO (Single Sign-On) với Google để người dùng đăng nhập an toàn.
- Ứng dụng nhận được access token để gọi API Google Cloud thay mặt người dùng.
Đây là tình huống điển hình cho web server applications trong OAuth 2.0, nơi server-side code xử lý token exchange bí mật. Kiến thức dựa trên tài liệu Google Identity cập nhật đến 2026 (OAuth 2.0 cho Web Server Apps).
📘 Tài liệu tham khảo:
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng là phương án thứ 4 (đã được đánh dấu [ĐÚNG] trong câu hỏi).
🛠️ Lý do chi tiết:
- Đây chính là Authorization Code Flow chuẩn của OAuth 2.0 dành cho web server apps (RFC 6749, cập nhật Google 2026).
- Bước 1: Redirect người dùng đến Google Consent Screen để SSO và cấp quyền (scopes).
- Bước 2-3: Nhận authorization code qua redirect URI (server-side, không lưu cookie client-side).
- Bước 4: Server app exchange code lấy access token từ Google Token Endpoint (sử dụng client secret bí mật), sau đó dùng token gọi API.
- Ưu điểm: Bảo mật cao (code chỉ dùng 1 lần, short-lived; token không expose cho browser), hỗ trợ refresh token cho long-lived access.
📋 Giải thích tất cả các phương án
Dưới đây là phân tích từng phương án một cách chi tiết. Tôi giữ nguyên văn bản gốc tiếng Anh của các lựa chọn, chỉ giải thích bằng tiếng Việt với emoji để nổi bật.
-
Phương án 1 (Sai - ❌):
- When a user arrives at your application, prompt them for their Google username and password.
- Store an SHA password hash in your application's database along with the user's username.
- The application authenticates to the Google Cloud API using HTTPs requests with the user's username and password hash in the Authorization request header.
Giải thích sai: Phương án này vi phạm nguyên tắc bảo mật cơ bản. Việc prompt và lưu hash mật khẩu (dù SHA) trên database là rủi ro cao (không dùng cho OAuth, dễ bị tấn công brute-force hoặc leak). Google Cloud API không hỗ trợ Basic Auth với username/password hash trong header. Đây là cách lỗi thời, không an toàn cho production.
-
Phương án 2 (Sai - ❌):
- When a user arrives at your application, prompt them for their Google username and password.
- Forward the user's username and password in an HTTPS request to the Google Cloud authorization server, and request an access token.
- The Google server validates the user's credentials and returns an access token to the application.
- The application uses the access token to call the Google Cloud API.
Giải thích sai: Đây là Resource Owner Password Credentials Grant (deprecated từ 2012, cấm hoàn toàn từ 2026 theo Google policy). Prompt và forward credentials trực tiếp phá vỡ mô hình delegated authorization, khuyến khích phishing và không dùng cho web apps (chỉ legacy native apps). Google không khuyến nghị, ưu tiên Authorization Code Flow.
-
Phương án 3 (Sai - ❌):
- When a user arrives at your application, route them to a Google Cloud consent screen with a list of requested permissions that prompts the user to sign in with SSO to their Google Account.
- After the user signs in and provides consent, your application receives an authorization code from a Google server.
- The Google server returns the authorization code to the user, which is stored in the browser's cookies.
- The user authenticates to the Google Cloud API using the authorization code in the cookie.
Giải thích sai: Bước 1-2 đúng một phần (Consent Screen và auth code), nhưng lưu code vào browser cookies là sai lầm bảo mật lớn (dễ bị XSS/CSRF steal). Authorization code phải được server app nhận qua redirect URI và exchange ngay lập tức (không để client-side dùng trực tiếp). User/browser không gọi API trực tiếp bằng code.
-
Phương án 4 (Đúng - ✅):
- When a user arrives at your application, route them to a Google Cloud consent screen with a list of requested permissions that prompts the user to sign in with SSO to their Google Account.
- After the user signs in and provides consent, your application receives an authorization code from a Google server.
- The application requests a Google Server to exchange the authorization code with an access token.
- The Google server responds with the access token that is used by the application to call the Google Cloud API.
Giải thích đúng: Hoàn hảo khớp Authorization Code Flow (web server). Server nhận code an toàn, exchange bằng client_id/secret (backend), token lưu server-side. Hỗ trợ PKCE cho thêm bảo mật (tùy chọn 2026). Đây là best practice cho Java web apps (sử dụng Google API Client Library).
🧠 Lời khuyên triển khai: Trong Java, dùng thư viện google-auth-library-oauth2-http hoặc Spring Security OAuth2. Đăng ký OAuth client ở Google Cloud Console với redirect URIs chính xác!
- A Push your source code to Artifact Registry.
- B Submit a Cloud Build job to push the image.
- C Use the pack build command with pack CLI.
- D Include the --source flag with the gcloud run deploy CLI command.
- E Include the --platform=kubernetes flag with the gcloud run deploy CLI command.
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 triển khai ứng dụng mới lên Cloud Run mà không cần sử dụng Dockerfile. Yêu cầu chính là:
- Xây dựng container image bằng các dịch vụ Google Cloud.
- Tất cả container images phải được push vào một kho chứa trung tâm (Artifact Registry) – đây là kho chứa image được quản lý tập trung trong tổ chức.
- Chọn hai phương án đúng để xây dựng container phù hợp.
Bối cảnh quan trọng (dựa trên kiến thức Google Cloud cập nhật đến 2026):
- Cloud Run hỗ trợ source-based deployment (triển khai từ mã nguồn trực tiếp) sử dụng Cloud Buildpacks – một công cụ tự động detect ngôn ngữ/framework và build image mà không cần Dockerfile.
- Quá trình build sẽ tự động push image vào Artifact Registry (mặc định hoặc chỉ định).
- Không cần build thủ công; Google Cloud tự động hóa qua CLI hoặc công cụ liên quan. 📘
Nguồn tham khảo:
- Cloud Run: Deploy from source (cập nhật 2025).
- Cloud Buildpacks overview (hỗ trợ pack CLI và gcloud integrate).
- gcloud run deploy reference (flags như --source).
✅ Đáp án đúng (Chọn hai)
Hai phương án đúng là:
- Use the pack build command with pack CLI.
- Include the --source flag with the gcloud run deploy CLI command.
Lý do lựa chọn:
- Cả hai đều sử dụng Cloud Buildpacks để tự động build image từ source code mà không cần Dockerfile.
- Image được build sẽ tự động push vào Artifact Registry (kho trung tâm), đáp ứng yêu cầu tổ chức.
- pack CLI: Công cụ chính thức của Buildpacks, build local hoặc remote, push trực tiếp vào Artifact Registry.
- gcloud run deploy --source: Trigger Cloud Build tự động build từ source (Git repo hoặc local dir), deploy luôn lên Cloud Run, image lưu ở Artifact Registry. 🛠️ Hoàn hảo cho serverless workflow!
📋 Giải thích tất cả các phương án (Đúng & Sai)
-
✅ Use the pack build command with pack CLI.
Đúng: Lệnhpack buildsử dụng Cloud Buildpacks để detect ngôn ngữ (Node.js, Python, v.v.), build image OCI chuẩn mà không cần Dockerfile. Có thể chỉ định--publishđể push trực tiếp vào Artifact Registry (ví dụ:pack build my-app --builder gcr.io/buildpacks/builder:v1 --publish gcr.io/PROJECT/REPO/my-app). Đáp ứng đầy đủ yêu cầu centrally managed repo. 🏗️ -
✅ Include the --source flag with the gcloud run deploy CLI command.
Đúng: Flag--sourcecho phép chỉ định source code (local dir hoặc Git URL), Cloud Run + Cloud Build sẽ tự động dùng Buildpacks build image không cần Dockerfile, push vào Artifact Registry, rồi deploy. Ví dụ:gcloud run deploy SERVICE --source . --region us-central1. Siêu tiện lợi cho CI/CD! 🚀 -
❌ Push your source code to Artifact Registry.
Sai: Artifact Registry chỉ lưu trữ container images (OCI format), không hỗ trợ push source code trực tiếp (như Git repo). Source code nên push vào Cloud Source Repositories, GitHub, hoặc dùng với Cloud Build/Run. Không build được image từ đây. 😵 -
❌ Submit a Cloud Build job to push the image.
Sai: Cloud Build cần build config (cloudbuild.yaml) hoặc Dockerfile để build. Không có Dockerfile, và submit job thủ công không tự động như Buildpacks. Hơn nữa, câu hỏi nhấn mạnh "without a Dockerfile" và dùng Google Cloud services mượt mà hơn, không phải submit job riêng lẻ. Phức tạp không cần thiết! ⚠️ -
❌ Include the --platform=kubernetes flag with the gcloud run deploy CLI command.
Sai: Flag--platform=managed(mặc định) cho Cloud Run serverless.--platform=kubernetesdùng cho Knative/Kubernetes Engine, không phải Cloud Run thuần (serverless containers). Không liên quan đến build image hay Artifact Registry, và không hỗ trợ build từ source trực tiếp như vậy. 🚫
Kết luận: Hai đáp án đúng tận dụng Buildpacks – giải pháp hiện đại, không Dockerfile, tích hợp Artifact Registry hoàn hảo cho enterprise! Nếu cần demo, dùng gcloud components install pack. 🎉
- A Create a Cloud SQL table that has TransactionId and CustomerId configured as primary keys. Use an incremental number for the TransactionId.
- B Create a Cloud SQL table that has TransactionId and CustomerId configured as primary keys. Use a random string (UUID) for the Transactionid.
- C Create a Cloud Spanner table that has TransactionId and CustomerId configured as primary keys. Use a random string (UUID) for the TransactionId.
- D Create a Cloud Spanner table that has TransactionId and CustomerId configured as primary keys. Use an incremental number for the TransactionId.
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ổ chức quản lý website thương mại điện tử trực tuyến, hiện chỉ phục vụ một vùng cụ thể (regional), nhưng sắp mở rộng toàn cầu. Nhiệm vụ là chọn cơ sở dữ liệu SQL và thiết kế schema bảng để scale theo sự phát triển, cụ thể tạo bảng lưu tất cả giao dịch khách hàng (customer transactions). Yêu cầu đảm bảo CustomerId (ID khách hàng) và TransactionId (ID giao dịch) là unique (duy nhất).
🔍 Phân tích yêu cầu chính:
- Scale toàn cầu: Cần database hỗ trợ horizontal scaling, global distribution với strong consistency (ACID transactions跨越 regions).
- Schema: Bảng với composite primary key (TransactionId + CustomerId) để đảm bảo tính unique (một khách hàng có nhiều giao dịch unique).
- Thách thức: Tránh hotspots (tập trung writes vào một shard) khi scale lớn, đặc biệt với global traffic.
📘 Dẫn nguồn:
- Google Cloud Spanner docs: Designing your schema | Cloud Spanner (cập nhật 2024-2026: Nhấn mạnh UUID cho PK để tránh hotspots).
- Cloud SQL limits: Quotas and limits | Cloud SQL (regional scaling, không true global).
✅ Đáp án đúng
Create a Cloud Spanner table that has TransactionId and CustomerId configured as primary keys. Use a random string (UUID) for the TransactionId.
Lý do lựa chọn 🛠️:
- Cloud Spanner là distributed SQL database hỗ trợ global scale với horizontal sharding tự động, strong consistency (TrueTime), lý tưởng cho ecommerce mở rộng thế giới mà không downtime.
- Composite PK (TransactionId, CustomerId): Đảm bảo unique (một CustomerId có nhiều TransactionId unique).
- UUID cho TransactionId: Phân bố random (high cardinality), tránh hotspots trên first column của PK (Spanner sharding theo leading key). Incremental ID sẽ gây bottleneck vì tất cả inserts mới vào cùng shard đầu tiên.
- Phù hợp scale tăng trưởng: Hàng tỷ rows/transactions global, throughput cao (hàng triệu QPS).
📋 Phân tí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 tiếng Anh). Tôi đánh dấu ✅ đúng hoặc ❌ sai, kèm giải thích chi tiết bằng tiếng Việt dựa trên kiến thức GCP mới nhất (2026).
-
❌ [SAI] Create a Cloud SQL table that has TransactionId and CustomerId configured as primary keys. Use an incremental number for the TransactionId.
Giải thích sai: Cloud SQL chỉ là regional SQL (MySQL/PostgreSQL), không scale global thực sự (chỉ read replicas multi-region, write vẫn single AZ/region). Incremental TransactionId gây sequential hotspots trong scaling (dù Cloud SQL không shard như Spanner). Không phù hợp mở rộng thế giới với traffic cao, dễ exceed quotas (max ~64TB/instance). -
❌ [SAI] Create a Cloud SQL table that has TransactionId and CustomerId configured as primary keys. Use a random string (UUID) for the Transactionid.
Giải thích sai: UUID tốt cho phân bố, nhưng Cloud SQL vẫn regional, không hỗ trợ global distribution với low-latency writes mọi nơi. Scaling giới hạn vertical/horizontal cơ bản (read replicas), không ACID global transactions. Với ecommerce global, latency cao và single failure point. -
✅ [ĐÚNG] Create a Cloud Spanner table that has TransactionId and CustomerId configured as primary keys. Use a random string (UUID) for the TransactionId.
Giải thích đúng: Như phần đáp án trên – Spanner lý tưởng cho global scale (multi-region configs: regional/3-zone/multi-region), UUID tránh hotspots (Spanner interleaving/split keys tự động). Hỗ trợ schema evolution, SQL chuẩn ANSI 2011+. -
❌ [SAI] Create a Cloud Spanner table that has TransactionId and CustomerId configured as primary keys. Use an incremental number for the TransactionId.
Giải thích sai: Spanner tuyệt vời cho global, nhưng incremental TransactionId (first in PK) gây severe hotspots – tất cả writes mới funnel vào shard đầu, throttle performance (chỉ ~few hundred QPS thay vì millions). Docs GCP cảnh báo rõ: "Use random or hashed values for leading key" (cập nhật 2026: SERVERS cải thiện nhưng vẫn recommend UUID).
🧠 Lưu ý bổ sung: Trong thực tế, PK nên là (CustomerId, TransactionId) để interleave (customer làm parent), tối ưu queries phổ biến (lọc theo customer). Test với Spanner emulator trước deploy!
📘 Tài liệu tham khảo thêm:
- Cloud Spanner Best Practices (hotspots & UUID).
- So sánh SQL vs Spanner: Choose the right database.