Ngân hàng đề — Google Cloud Professional Cloud Developer

Tìm thấy 358 câu.

Câu 291
You use Cloud Build to build and test container images prior to deploying them to Cloud Run. Your images are stored in Artifact Registry. You need to ensure that only container images that have passed testing are deployed. You want to minimize operational overhead. What should you do?
  1. A Deploy a new revision to a Cloud Run service. Assign a tag that allows access to the revision at a specific URL without serving traffic. Test that revision again. Migrate the traffic to the Cloud Run service after you confirm that the new revision is performing as expected.
  2. B Enable Binary Authorization on your Cloud Run service. Create an attestation if the container image has passed all tests. Configure Binary Authorization to allow only images with appropriate attestation to be deployed to the Cloud Run service.
  3. C Create a GKE cluster. Verify that all tests have passed, and then deploy the image to the GKE cluster.
  4. D Configure build provenance on your Cloud Build pipeline. Verify that all the tests have passed, and then deploy the image to a Cloud Run service.
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 quy trình xây dựng, kiểm tra và triển khai container images trên Google Cloud Platform (GCP). Cụ thể:

  • Bạn sử dụng Cloud Build để build và test các container images trước khi deploy lên Cloud Run.
  • Images được lưu trữ trong Artifact Registry.
  • Yêu cầu chính: Đảm bảo chỉ những images đã qua kiểm tra (passed testing) mới được deploy lên Cloud Run.
  • Mục tiêu: Giảm thiểu operational overhead (tức là giảm công sức vận hành thủ công, tự động hóa quy trình một cách đơn giản nhất). 🛠️ Đây là tình huống thực tế trong CI/CD pipeline trên GCP, nơi cần kiểm soát chất lượng images để tránh deploy version lỗi, đồng thời giữ quy trình tự động và ít can thiệp tay.

📘 Kiến thức cập nhật (đến 2026): Theo tài liệu GCP mới nhất (Google Cloud docs 2024-2026), Binary Authorization (nay tích hợp chặt chẽ với Cloud Run và Artifact Registry) là giải pháp chuẩn cho việc attest và verify images trước deploy. Không có thay đổi lớn từ phiên bản trước; nó hỗ trợ PKI-based attestation để enforce policy.
Nguồn tham khảo:

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Enable Binary Authorization on your Cloud Run service. Create an attestation if the container image has passed all tests. Configure Binary Authorization to allow only images with appropriate attestation to be deployed to the Cloud Run service.

Lý do chọn:

  • Phương án này tự động hóa hoàn toàn quy trình: Sau khi test pass trong Cloud Build, tạo attestation (chứng nhận số) gắn với image trong Artifact Registry.
  • Binary Authorization trên Cloud Run sẽ block mọi deploy nếu image thiếu attestation phù hợp, đảm bảo chỉ images "đã qua test" mới chạy.
  • Minimize operational overhead tối ưu: Không cần can thiệp thủ công, tích hợp native với Cloud Build/Run/Artifact Registry, hỗ trợ policy PKI-based. Đây là best practice GCP cho supply chain security (SLSA framework).
    🛡️ Kết quả: An toàn cao, zero-downtime deploy, scale tự động.

📋 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 tiếng Anh. Phần giải thích hoàn toàn bằng tiếng Việt với lý do đúng/sai rõ ràng:

  • ❌ [SAI] Deploy a new revision to a Cloud Run service. Assign a tag that allows access to the revision at a specific URL without serving traffic. Test that revision again. Migrate the traffic to the Cloud Run service after you confirm that the new revision is performing as expected.
    Giải thích sai: Phương án này yêu cầu deploy revision mới trước, gán tag để test riêng (qua URL không traffic), rồi migrate thủ công sau khi confirm. Không minimize overhead vì cần nhiều bước thủ công (deploy-test-migrate), dễ lỗi, không enforce tự động "chỉ passed images". Cloud Run tag chỉ hỗ trợ routing, không verify test results.

  • ✅ [ĐÚNG] Enable Binary Authorization on your Cloud Run service. Create an attestation if the container image has passed all tests. Configure Binary Authorization to allow only images with appropriate attestation to be deployed to the Cloud Run service.
    Giải thích đúng: Như đã phân tích ở trên, đây là giải pháp native và tự động của GCP. Attestation từ Cloud Build (sau test pass) được Binary Authorization verify policy-level, block deploy nếu không hợp lệ. Hoàn hảo cho yêu cầu, overhead thấp nhất.

  • ❌ [SAI] Create a GKE cluster. Verify that all tests have passed, and then deploy the image to the GKE cluster.
    Giải thích sai: Tạo GKE cluster để verify và deploy là overkill, vì câu hỏi yêu cầu deploy lên Cloud Run (serverless, không cần cluster). Overhead cao (quản lý GKE tốn kém), không liên quan trực tiếp, và không tự động enforce trên Cloud Run.

  • ❌ [SAI] Configure build provenance on your Cloud Build pipeline. Verify that all the tests have passed, and then deploy the image to a Cloud Run service.
    Giải thích sai: Build provenance chỉ ghi lại metadata về build process (ai build, từ source nào), không chứng nhận "test passed". Không enforce deploy policy trên Cloud Run; vẫn cần verify thủ công sau đó. Không đủ mạnh để block images fail test, overhead vẫn cao do thiếu automation đầy đủ.

🧠 Kết luận: Binary Authorization là lựa chọn tối ưu, phù hợp 100% với CI/CD secure trên GCP! Nếu cần demo code/pipeline, hãy hỏi thêm nhé. 🚀

Câu 292 Chọn nhiều đáp án
You are developing a scalable web application for internal users. Your organization uses Google Workspace. You need to set up authentication to the application for the users, and then deploy the application on Google Cloud. You plan to use cloud-native features, and you want to minimize infrastructure management effort. What should you do? (Choose two.)
  1. A Create a Compute Engine VM, configure a web server, and deploy the application in a VPC.
  2. B Containerize the application, and deploy it as a Cloud Run service.
  3. C Configure Cloud SQL database with a table containing the users and password hashes. Add an authentication screen to ensure that only internal users can access the application.
  4. D Configure Identity Aware Proxy, and grant the roles/iap.httpsResourceAccessor IAM role to the users that need to access the application.
  5. E Configure Identity Aware Proxy, and grant the roles/iap.tunnelResourceAccessor IAM role to the users that need to access the application.
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 phát triển một ứng dụng web có khả năng mở rộng (scalable) dành cho người dùng nội bộ (internal users) trong tổ chức sử dụng Google Workspace. Nhiệm vụ chính là:

  • Thiết lập xác thực (authentication) cho ứng dụng để chỉ người dùng nội bộ truy cập được.
  • Triển khai (deploy) ứng dụng lên Google Cloud.
  • Ưu tiên sử dụng các tính năng cloud-native (như serverless, managed services).
  • Giảm thiểu nỗ lực quản lý hạ tầng (minimize infrastructure management effort).

Đây là câu hỏi chọn 2 đáp án đúng, tập trung vào cách deploy ứng dụng serverless và tích hợp xác thực với Google identities (từ Google Workspace) một cách tự động, không cần quản lý server thủ công. Câu hỏi nhấn mạnh tính cloud-native để tránh các giải pháp truyền thống như VM.

✅ Đáp án đúng (chọn 2)

  • Containerize the application, and deploy it as a Cloud Run service.
  • Configure Identity Aware Proxy, and grant the roles/iap.httpsResourceAccessor IAM role to the users that need to access the application.

Lý do lựa chọn:

  • Cloud Run là dịch vụ serverless container hoàn toàn managed, tự động scale, không cần quản lý server → phù hợp minimize infra effort và cloud-native.
  • Identity-Aware Proxy (IAP) tích hợp trực tiếp với Google Workspace để xác thực người dùng nội bộ qua IAM roles. Role iap.httpsResourceAccessor dành riêng cho web app HTTPS, cho phép kiểm soát truy cập chi tiết mà không cần code auth thủ công.

📋 Giải thích tất cả các phương án

  • ✅ Containerize the application, and deploy it as a Cloud Run service.
    Phương án này ĐÚNG vì Cloud Run cho phép đóng gói app vào container (Docker), deploy serverless với auto-scaling, zero-downtime, và tích hợp native với GCP services. Không cần quản lý VM hay server, hoàn toàn phù hợp yêu cầu "cloud-native" và "minimize infrastructure management". Cloud Run hỗ trợ traffic splitting, revisions, và integrate dễ dàng với IAP cho auth. (Cập nhật 2026: Cloud Run vẫn là lựa chọn hàng đầu cho web apps stateless).

  • ❌ Create a Compute Engine VM, configure a web server, and deploy the application in a VPC.
    Phương án này SAI vì sử dụng VM Compute Engine yêu cầu quản lý thủ công (provision, patch OS, scale, monitor web server như Nginx/Apache), không cloud-native. VPC chỉ là networking cơ bản, không giảm effort như serverless. Không phù hợp minimize infra.

  • ❌ Configure Cloud SQL database with a table containing the users and password hashes. Add an authentication screen to ensure that only internal users can access the application.
    Phương án này SAI vì tự xây dựng auth system với DB (Cloud SQL) và màn hình login → phức tạp, không an toàn (manage password hashes, vulnerable to breaches), không tận dụng Google Workspace identities. Không cloud-native cho auth, vi phạm minimize effort và không integrate native.

  • ✅ Configure Identity Aware Proxy, and grant the roles/iap.httpsResourceAccessor IAM role to the users that need to access the application.
    Phương án này ĐÚNG vì IAP là proxy layer bảo vệ app bằng Google sign-in (tích hợp Workspace), kiểm soát truy cập granular qua IAM. Role iap.httpsResourceAccessor chính xác cho web/HTTPS traffic, grant cho users/groups để chỉ internal access. Zero-config cho app, hoàn toàn managed. (Cập nhật 2026: IAP hỗ trợ OAuth 2.0, OIDC, và audit logs đầy đủ).

  • ❌ Configure Identity Aware Proxy, and grant the roles/iap.tunnelResourceAccessor IAM role to the users that need to access the application.
    Phương án này SAI vì role iap.tunnelResourceAccessor dành cho TCP/SSH tunnels (như Cloud SQL proxy hoặc internal services), KHÔNG phù hợp web app HTTPS. Sử dụng sai role sẽ không authorize đúng traffic, dẫn đến access denied.

🛠️ Khuyến nghị triển khai thực tế

  • Bước 1: Containerize app → gcloud run deploy.
  • Bước 2: Enable IAP trên Cloud Run service → Grant role iap.httpsResourceAccessor cho Google Workspace groups.
  • Kết hợp: IAP frontend cho Cloud Run → Secure, scalable, zero-infra.

📘 Tài liệu tham khảo (cập nhật mới nhất GCP 2026)

Câu 293
You work for an ecommerce company, and you are responsible for deploying and managing multiple APIs. The operations team wants to review the traffic patterns in the orders-prod and users-prod environments. These are the only environments in the store-prod environment group. You want to follow Google-recommended practices. What should you do?
  1. A Assign the Apigee Analytics Viewer IAM role to the operations team for both environments. Use Cloud Monitoring to review traffic patterns.
  2. B Assign the Apigee Analytics Viewer IAM role to the operations team for both environments. Use Apigee API Analytics to review traffic patterns.
  3. C Assign the Apigee API Reader IAM role to each user of the operations team for both environments. Use Cloud Monitoring to review traffic patterns.
  4. D Assign the Apigee API Reader IAM role to each user of the operations team for both environments. Use Apigee API Analytics to review traffic patterns.
Xem giải thích

🧩 Phân tích chi tiết nội dung câu hỏi

Câu hỏi thuộc chủ đề Apigee (nền tảng quản lý API của Google Cloud), không phải AWS như mô tả ban đầu (có thể là nhầm lẫn). Bạn làm việc cho một công ty thương mại điện tử, chịu trách nhiệm triển khai và quản lý nhiều API. Nhóm vận hành (operations team) muốn xem xét các mẫu lưu lượng truy cập (traffic patterns) trong hai môi trường orders-prod và users-prod – đây là hai môi trường duy nhất thuộc nhóm môi trường store-prod. Bạn cần tuân thủ các thực hành được Google khuyến nghị để cấp quyền và công cụ phù hợp.

Mục tiêu chính:

  • Cấp quyền IAM phù hợp cho nhóm operations team (không phải từng user cá nhân).
  • Sử dụng công cụ phân tích traffic patterns chuyên biệt cho Apigee.
  • Áp dụng kiến thức mới nhất đến năm 2026: Apigee hybrid/service vẫn ưu tiên Apigee Analytics cho traffic insights, tích hợp sâu với IAM roles như Analytics Viewer (theo docs Google Cloud cập nhật 2024-2026).

📘 Tài liệu tham khảo:

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Assign the Apigee Analytics Viewer IAM role to the operations team for both environments. Use Apigee API Analytics to review traffic patterns.

Lý do 🛠️:

  • Apigee Analytics Viewer IAM role là role được Google khuyến nghị dành riêng cho việc xem dữ liệu phân tích (analytics data) như traffic patterns, metrics (requests, latency, errors) mà không cần quyền chỉnh sửa. Gán role này cho toàn bộ operations team (nhóm) là thực hành tốt, hiệu quả hơn gán từng user.
  • Apigee API Analytics là công cụ chính thức, chuyên sâu để xem traffic patterns ở cấp environment/group (như store-prod chứa orders-prod và users-prod). Nó cung cấp dashboards, reports chi tiết về API traffic – phù hợp Google best practices.
  • Không dùng Cloud Monitoring vì đó là công cụ chung cho GCP monitoring, không tích hợp sâu analytics Apigee-specific.

❌ Giải thích tất cả các phương án (đúng/sai)

  • [SAI] Assign the Apigee Analytics Viewer IAM role to the operations team for both environments. Use Cloud Monitoring to review traffic patterns.
    ❌ Sai vì: Role đúng (Apigee Analytics Viewer phù hợp cho team xem analytics), nhưng công cụ sai. Cloud Monitoring dùng cho metrics hệ thống GCP chung (CPU, logs), không phải traffic patterns API-specific của Apigee. Phải dùng Apigee API Analytics để xem dữ liệu chi tiết như proxy flows, không theo best practices.

  • [ĐÚNG] Assign the Apigee Analytics Viewer IAM role to the operations team for both environments. Use Apigee API Analytics to review traffic patterns.
    ✅ Đúng vì: Kết hợp hoàn hảo role IAM chuyên analytics (gán cho team, áp dụng cả hai environments) + công cụ Apigee API Analytics (dashboards traffic, errors, latency theo real-time/historical). Đây là Google-recommended practice cho Apigee environments/groups.

  • [SAI] Assign the Apigee API Reader IAM role to each user of the operations team for both environments. Use Cloud Monitoring to review traffic patterns.
    ❌ Sai kép: Role Apigee API Reader chỉ cho phép đọc config API proxies/products/environments (không xem analytics data). Gán từng user (không phải team/group) kém hiệu quả. Cloud Monitoring không hỗ trợ Apigee traffic patterns sâu. Không tuân thủ best practices.

  • [SAI] Assign the Apigee API Reader IAM role to each user of the operations team for both environments. Use Apigee API Analytics to review traffic patterns.
    ❌ Sai vì: Role Apigee API Reader thiếu quyền truy cập analytics (chỉ đọc metadata API, không metrics/traffic). Gán từng user không scalable. Apigee API Analytics yêu cầu role Analytics Viewer mới xem được data – vi phạm IAM least privilege và best practices.

🧩 Tóm tắt key takeaway: Ưu tiên role/group-based IAM + tool native Apigee để scalable và secure! 🚀

Câu 294
You are migrating a containerized application to Cloud Run. You plan to use Cloud Build to build your container image and push it to Artifact Registry, and you plan to use Cloud Deploy to deploy the image to production. You need to ensure that only secure images are deployed to production. What should you do?
  1. A Use Cloud Armor in front of Cloud Run to protect the container image from threats.
  2. B Use Artifact Analysis to scan the image for vulnerabilities. Use Cloud Key Management Service to encrypt the image to be deployed to production.
  3. C Use Secret Manager to store the encrypted image. Deploy this image to production.
  4. D Use Binary Authorization to enforce a policy that only allows images that have been signed with a trusted key to be deployed to production.
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 quy trình di chuyển ứng dụng container hóa lên Cloud Run trên Google Cloud Platform (GCP). Quy trình cụ thể bao gồm:

  • Sử dụng Cloud Build để build container image và push lên Artifact Registry.
  • Sử dụng Cloud Deploy để triển khai image lên môi trường production.
  • Mục tiêu chính: Đảm bảo chỉ các image an toàn (secure images) mới được triển khai lên production, tránh rủi ro từ image độc hại hoặc chưa được kiểm tra.

🛠️ Bối cảnh thực tế: Trong môi trường CI/CD trên GCP, việc kiểm soát image là rất quan trọng để ngăn chặn supply chain attacks. Câu hỏi yêu cầu giải pháp enforce policy (áp đặt chính sách) tại thời điểm deploy, không chỉ scan mà còn chặn deploy nếu không đạt chuẩn. Đây là chủ đề liên quan đến security best practices cho container deployment trên GCP (không phải AWS, dù đề cập, vì toàn bộ dịch vụ là GCP).

📘 Kiến thức cập nhật đến 2026: Theo tài liệu GCP mới nhất (Cloud Run, Cloud Deploy v2, Binary Authorization tích hợp với Cloud Deploy từ 2023+), Binary Authorization là giải pháp chuẩn cho việc này, hỗ trợ policy-based deployment với image signing.

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Use Binary Authorization to enforce a policy that only allows images that have been signed with a trusted key to be deployed to production.

Lý do chọn 🏆:

  • Binary Authorization (BinAuthz) là dịch vụ GCP chuyên dụng để kiểm soát và enforce policy tại runtime deploy. Nó yêu cầu image phải được ký bởi key đáng tin cậy (trusted key) trước khi Cloud Deploy cho phép triển khai lên production.
  • Tích hợp trực tiếp với Cloud Deploy, Cloud Build và Artifact Registry: Image từ Cloud Build có thể được ký tự động, sau đó BinAuthz kiểm tra signature trước khi deploy.
  • Đảm bảo chỉ secure images (đã verify) mới qua, ngăn chặn image chưa scan hoặc tampered.
  • Nguồn tham khảo: GCP Docs - Binary Authorization & Cloud Deploy Security (cập nhật 2025).

❌ Giải thích tất cả các phương án (đúng/sai)

  • [SAI] Use Cloud Armor in front of Cloud Run to protect the container image from threats.
    ❌ Sai vì: Cloud Armor là Web Application Firewall (WAF) bảo vệ traffic runtime (lớp 7) đến Cloud Run, không kiểm soát image tại thời điểm deploy. Nó chặn threats từ request người dùng (DDoS, SQLi), chứ không verify hoặc block image chưa secure trước khi push/deploy. Không liên quan đến Artifact Registry hay Cloud Deploy.

  • [SAI] Use Artifact Analysis to scan the image for vulnerabilities. Use Cloud Key Management Service to encrypt the image to be deployed to production.
    ❌ Sai vì:

    • Artifact Analysis (từ Container Analysis) chỉ scan vulnerabilities (CVEs) và báo cáo, nhưng không enforce/block deploy tự động (cần tích hợp thêm policy).
    • KMS dùng để quản lý key mã hóa, nhưng Artifact Registry đã tự động encrypt at-rest (server-side encryption), không cần encrypt thủ công image trước deploy. Kết hợp này không đảm bảo "only secure images" mà chỉ scan + encrypt (không chặn deploy image vulnerable).
  • [SAI] Use Secret Manager to store the encrypted image. Deploy this image to production.
    ❌ Sai vì: Secret Manager chỉ lưu secrets nhỏ (API keys, passwords < 64KB), không dùng để lưu trữ container image lớn (hàng GB). Image phải ở Artifact Registry. Việc "store encrypted image" ở đây không khả thi và không enforce security policy cho deploy.

  • [ĐÚNG] Use Binary Authorization to enforce a policy that only allows images that have been signed with a trusted key to be deployed to production.
    ✅ Đúng vì: Như giải thích trên, đây là giải pháp chuẩn và toàn diện cho yêu cầu "only secure images". Policy có thể yêu cầu signature + attestations (từ scan tools như Trivy/Syft), tích hợp liền mạch với Cloud Deploy để attest & attest trước production.

🧠 Lời khuyên thực hành: Kết hợp BinAuthz với Attestation từ Cloud Build (cosign signatures) và Container Analysis để full security pipeline. Test trên môi trường dev trước! 🚀

Câu 295
Your team uses Cloud Storage for a video and image application that was recently migrated to Google Cloud. Following a viral surge, users are reporting application instability, coinciding with a 10x increase in HTTP 429 error codes from Cloud Storage APIs. You need to resolve the errors and establish a long-term solution. You want to ensure that the application remains stable if the load increases again in the future. What should you do?
  1. A Optimize the application code to reduce unnecessary calls to Cloud Storage APIs to prevent HTTP 429 errors.
  2. B Compress the video and images files to reduce their size, and minimize storage costs and bandwidth usage. Implement a custom throttling mechanism in the application that limits the number of concurrent API calls.
  3. C Migrate all image and video data to Firestore. Replace the Cloud Storage APIs in the application code with the new Firestore database.
  4. D Implement a retry strategy with exponential backoff for requests that encounter HTTP 429 errors.
Xem giải thích

🧩 Phân tích nội dung câu hỏi

Câu hỏi mô tả một ứng dụng xử lý video và hình ảnh đã migrate sang Google Cloud, sử dụng Cloud Storage làm nơi lưu trữ. Sau một sự kiện viral, lưu lượng truy cập tăng đột biến 10x, dẫn đến ứng dụng không ổn định và lỗi HTTP 429 (Too Many Requests) từ các API của Cloud Storage tăng vọt. Nhiệm vụ là:

  • Giải quyết ngay lập tức các lỗi 429.
  • Xây dựng giải pháp dài hạn để ứng dụng ổn định nếu load tăng lại. Mục tiêu chính là xử lý rate limiting (giới hạn tốc độ yêu cầu) của Cloud Storage, vốn có quota mặc định (ví dụ: 1000-5000 requests/giây tùy bucket class, theo docs cập nhật 2025). Không cần thay đổi hạ tầng lớn, mà tập trung vào best practice cho resiliency. 📘 Tài liệu tham khảo: Cloud Storage quotas & limits, Best practices for retries.

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Implement a retry strategy with exponential backoff for requests that encounter HTTP 429 errors.

Lý do:

  • HTTP 429 là lỗi rate limit/quota exceeded của Cloud Storage, thường tạm thời và tự recover sau vài giây/phút. 🛠️ Exponential backoff (tăng dần thời gian chờ giữa các retry, ví dụ: 1s → 2s → 4s → max 60s) là best practice chính thức từ Google Cloud (cập nhật 2025), giúp tránh "thundering herd" (đám đông yêu cầu đồng thời làm tình trạng tệ hơn).
  • Giải pháp này ngay lập tức giảm lỗi và dài hạn làm ứng dụng resilient với surge traffic, không cần thay đổi code lớn hay migrate data. Hỗ trợ qua client libraries (Node.js, Python, etc.) với retryConfiguration. ✅ Hoàn hảo cho long-term stability!

❌ Phân tích tất cả các phương án

Dưới đây là giải thích chi tiết từng lựa chọn, giữ nguyên văn bản gốc bằng tiếng Anh:

  • Phương án SAI: Optimize the application code to reduce unnecessary calls to Cloud Storage APIs to prevent HTTP 429 errors.
    ❌ Sai vì: Tối ưu code để giảm calls là tốt chung, nhưng không giải quyết gốc rễ surge 10x (có thể vẫn quá tải quota dù đã optimize). Không phải long-term solution vì không xử lý retry khi hit limit. Chỉ là preventive chứ không resilient.

  • Phương án SAI: Compress the video and images files to reduce their size, and minimize storage costs and bandwidth usage. Implement a custom throttling mechanism in the application that limits the number of concurrent API calls.
    ❌ Sai vì: Compress giúp tiết kiệm chi phí/băng thông, nhưng không giảm số lượng API calls (vẫn 10x requests). Custom throttling tự implement rủi ro cao (khó tune đúng quota động của Cloud Storage), dễ gây under-utilization hoặc vẫn 429. Google khuyên dùng built-in retry thay vì custom. Không scalable cho future surges.

  • Phương án SAI: Migrate all image and video data to Firestore. Replace the Cloud Storage APIs in the application code with the new Firestore database.
    ❌ Sai vì: Firestore là NoSQL database cho structured data, KHÔNG phù hợp lưu video/hình lớn (giới hạn 1MB/document, chi phí cao cho blobs). Migrate tốn kém, downtime cao, và Firestore có quota riêng (500 writes/sec), vẫn dễ 429. Cloud Storage mới là nơi lý tưởng cho unstructured media (unlimited scale).

  • Phương án ĐÚNG: Implement a retry strategy with exponential backoff for requests that encounter HTTP 429 errors.
    ✅ Đúng vì: Như giải thích trên, đây là giải pháp chuẩn từ Google Cloud docs (2025), xử lý chính xác 429 với jitter/backoff để tránh overload. Dễ implement (ví dụ: Google Cloud Storage client libs tự hỗ trợ withRetries), zero-downtime, và đảm bảo stability dài hạn. 🏆 Best choice!

Kết luận: Áp dụng ngay exponential backoff để fix và scale! 🚀 Nếu cần code sample, tham khảo Storage Client Libraries.

Câu 296
You are developing a container build pipeline for an application hosted on GKE. You have the following requirements:

• Only images that are created using your build pipeline should be deployed on your GKE cluster.
• All code and build artifacts should remain within your environment and protected from data exfiltration.

How should you build the pipeline?
  1. A 1. Create a build pipeline by using Cloud Build with the default worker pool.
    2. Deploy container images to a private container registry in your VPC.
    3. Create a VPC firewall policy in your project that denies all egress and ingress traffic to public networks.
  2. B 1. Create a build pipeline by using Cloud Build with a private worker pool.
    2. Use VPC Service Controls to place all components and services in your CI/CD pipeline inside a security perimeter.
    3. Configure your GKE cluster to only allow container images signed by Binary Authorization.
  3. C 1. Create a build pipeline by using Cloud Build with a private worker pool.
    2. Configure the CI/CD pipeline to build container images and store them in Artifact Registry.
    3. Configure Artifact Registry to encrypt container images by using customer-managed encryption keys (CMEK).
  4. D 1. Create a build pipeline by using Cloud Build with the default worker pool.
    2. Configure the CI/CD pipeline to build container images and store them in Artifact Registry.
    3. Configure your GKE cluster to only allow container images signed by Binary Authorization.
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 xây dựng pipeline build container cho ứng dụng chạy trên GKE (Google Kubernetes Engine) với hai yêu cầu chính:
✅ Chỉ cho phép deploy các container images được tạo từ pipeline build của bạn lên cluster GKE.
✅ Tất cả code và build artifacts phải giữ nguyên trong môi trường của bạn, bảo vệ chống data exfiltration (rò rỉ dữ liệu ra ngoài).

Mục tiêu là thiết kế pipeline an toàn, kín đáo, sử dụng các dịch vụ Google Cloud như Cloud Build, Artifact Registry, VPC Service Controls, Binary Authorization để đảm bảo:

  • Build diễn ra trong môi trường private (không dùng worker public).
  • Tạo "rào chắn" bảo vệ dữ liệu không thoát ra ngoài.
  • Xác thực images chỉ từ nguồn đáng tin cậy (signed).

Đây là câu hỏi kiểu multiple steps (các bước thực hiện theo thứ tự), kiểm tra kiến thức sâu về bảo mật CI/CD trên GCP (cập nhật đến 2026: Cloud Build hỗ trợ private pools đầy đủ, VPC Service Controls tích hợp sâu với GKE/Artifact Registry, Binary Authorization hỗ trợ policy-based signing với cosign).

📘 Tài liệu tham khảo:

✅ Đáp án đúng: Phương án thứ 2

1. Create a build pipeline by using Cloud Build with a private worker pool.
2. Use VPC Service Controls to place all components and services in your CI/CD pipeline inside a security perimeter.
3. Configure your GKE cluster to only allow container images signed by Binary Authorization.

Lý do chọn đáp án này 🛠️:

  • Bước 1: Private worker pool của Cloud Build chạy hoàn toàn trong VPC private của bạn, tránh sử dụng worker public (có nguy cơ exfil data qua internet). Điều này đảm bảo code/artifacts không rời khỏi môi trường.
  • Bước 2: VPC Service Controls tạo security perimeter bao quanh toàn bộ pipeline (Cloud Build, GKE, Artifact Registry), chặn data exfiltration bằng cách kiểm soát flow dữ liệu giữa services – chỉ allow internal traffic, block egress ra ngoài.
  • Bước 3: Binary Authorization (Attestor policy) chỉ cho GKE deploy images đã signed từ pipeline (qua Cloud Build steps), loại bỏ images từ nguồn khác.
    Kết hợp hoàn hảo ba yêu cầu, tuân thủ best practices bảo mật GCP 2026.

📋 Giải thích chi tiết từng phương án

  • ❌ Phương án 1 (SAI):
    1. Create a build pipeline by using Cloud Build with the default worker pool.
    2. Deploy container images to a private container registry in your VPC.
    3. Create a VPC firewall policy in your project that denies all egress and ingress traffic to public networks.
    Lý do sai: Default worker pool dùng Google-managed public workers (chạy ngoài VPC), dễ bị exfiltration code/artifacts ra internet → vi phạm yêu cầu giữ data trong environment. Firewall deny tất cả traffic quá cực đoan, block cả Google APIs cần thiết (như Artifact Registry pull), gây downtime pipeline. Private registry tốt nhưng không cứu vãn được.

  • ✅ Phương án 2 (ĐÚNG): (Đã giải thích ở trên) – Hoàn chỉnh, kín đáo, chống exfil tối ưu.

  • ❌ Phương án 3 (SAI):
    1. Create a build pipeline by using Cloud Build with a private worker pool.
    2. Configure the CI/CD pipeline to build container images and store them in Artifact Registry.
    3. Configure Artifact Registry to encrypt container images by using customer-managed encryption keys (CMEK).
    Lý do sai: Private pool và Artifact Registry tốt (giữ data internal), nhưng CMEK chỉ encrypt at-rest/transit, không chống exfiltration (data vẫn có thể leak nếu có lỗ hổng) và không enforce chỉ images từ pipeline (không có signing/check). Thiếu perimeter bảo vệ toàn diện.

  • ❌ Phương án 4 (SAI):
    1. Create a build pipeline by using Cloud Build with the default worker pool.
    2. Configure the CI/CD pipeline to build container images and store them in Artifact Registry.
    3. Configure your GKE cluster to only allow container images signed by Binary Authorization.
    Lý do sai: Default worker pool public → code/artifacts dễ exfil ra ngoài, vi phạm yêu cầu cốt lõi. Binary Authorization và Artifact Registry tốt cho enforce images, nhưng không fix được rủi ro build phase.

🧠 Kết luận: Phương án 2 là unique solution kết hợp private build + perimeter + signing, phù hợp zero-trust CI/CD trên GCP!

Câu 297
You are a developer at a company that operates an ecommerce website. The website stores the customer order data in a Cloud SQL for PostgreSQL database. Data scientists on the marketing team access this data to run their reports. Every time they run these reports, the website's performance is negatively affected. You want to provide access to up-to-date customer order datasets without affecting your website. What should you do?
  1. A Configure Cloud Scheduler to run an hourly Cloud Function that exports the data from the Cloud SQL database into CSV format and sends the data to a Cloud Storage bucket.
  2. B Set up a Bigtable table for the data science team. Configure the application to perform dual writes to both Cloud SQL and Bigtable simultaneously.
  3. C Set up a BigQuery dataset for the data science team. Configure Datastream to replicate the relevant Cloud SQL tables in BigQuery.
  4. D Create a clone of the PostgreSQL database instance for the data science team. Schedule a job to create a new clone every 15 minutes.
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 một công ty vận hành website thương mại điện tử (ecommerce), lưu trữ dữ liệu đơn hàng khách hàng trong cơ sở dữ liệu Cloud SQL for PostgreSQL (một dịch vụ RDBMS managed trên Google Cloud). Nhóm data scientists của bộ phận marketing cần truy cập dữ liệu này để chạy báo cáo, nhưng mỗi lần họ chạy, hiệu suất website bị ảnh hưởng tiêu cực (do các query báo cáo nặng làm overload database OLTP chính).
Mục tiêu: Cung cấp quyền truy cập dữ liệu đơn hàng cập nhật mới nhất (up-to-date) cho data scientists mà không ảnh hưởng đến website.
🛠️ Vấn đề cốt lõi: Cần tách biệt workload OLTP (transactional cho website) khỏi OLAP (analytical cho báo cáo), sử dụng replication real-time/low-latency để giữ dữ liệu tươi mới, tránh đọc trực tiếp từ database chính.
📘 Kiến thức cập nhật (GCP 2026): Theo tài liệu chính thức Google Cloud (cập nhật Q1/2026), Datastream hỗ trợ CDC (Change Data Capture) từ Cloud SQL PostgreSQL sang BigQuery, đảm bảo replication near real-time (latency <1 phút), tối ưu cho analytics mà không tải database nguồn.
Nguồn tham khảo:

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Set up a BigQuery dataset for the data science team. Configure Datastream to replicate the relevant Cloud SQL tables in BigQuery.

Lý do:

  • 🟢 BigQuery là data warehouse serverless lý tưởng cho analytical workloads (báo cáo lớn), hỗ trợ SQL chuẩn và ML tích hợp, phù hợp data scientists.
  • Datastream tự động replicate dữ liệu từ Cloud SQL PostgreSQL sang BigQuery qua CDC, đảm bảo up-to-date (near real-time, latency thấp ~30 giây - 1 phút), chỉ đọc từ source (không write thêm), không ảnh hưởng hiệu suất website.
  • Giải pháp scalable, managed, chi phí thấp (pay-per-use), và hỗ trợ schema evolution (cập nhật 2025+). Không cần dual writes hay export thủ công.
    ✅ Hoàn hảo khớp yêu cầu: Tách biệt hoàn toàn workload, dữ liệu tươi mới cho báo cáo.

📋 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, đánh dấu ✅ Đúng hoặc ❌ Sai, kèm lý do bằng tiếng Việt:

  • ❌ [SAI] Configure Cloud Scheduler to run an hourly Cloud Function that exports the data from the Cloud SQL database into CSV format and sends the data to a Cloud Storage bucket.
    🧨 Lý do sai: Export hàng giờ (hourly) chỉ cung cấp dữ liệu lỗi thời (stale data), không "up-to-date". Quá trình export qua Cloud Function vẫn query nặng trên Cloud SQL, vẫn ảnh hưởng hiệu suất website. CSV/Storage không tối ưu cho analytical queries (cần load vào BigQuery mới dùng được), phức tạp và không real-time. Không phải best practice cho CDC.

  • ❌ [SAI] Set up a Bigtable table for the data science team. Configure the application to perform dual writes to both Cloud SQL and Bigtable simultaneously.
    🧨 Lý do sai: Bigtable là NoSQL wide-column store cho high-throughput OLTP/key-value (không phù hợp relational order data với joins phức tạp cho báo cáo). Dual writes tăng latency writes cho ứng dụng website (mỗi transaction write 2 nơi), ảnh hưởng hiệu suất chính, rủi ro inconsistency nếu một bên fail. Data scientists khó query analytical trên Bigtable (thiếu SQL full). Không giải quyết vấn đề read-heavy.

  • ✅ [ĐÚNG] Set up a BigQuery dataset for the data science team. Configure Datastream to replicate the relevant Cloud SQL tables in BigQuery.
    🟢 Lý do đúng: Như phân tích trên, Datastream CDC đảm bảo replication one-way read-only, near real-time, zero-impact đến source DB. BigQuery dataset riêng cho team, hỗ trợ federated queries và slot-based pricing (cập nhật 2026). Best practice cho hybrid OLTP/OLAP.

  • ❌ [SAI] Create a clone of the PostgreSQL database instance for the data science team. Schedule a job to create a new clone every 15 minutes.
    🧨 Lý do sai: Clone là point-in-time snapshot lỗi thời 15 phút, không "up-to-date". Tạo clone định kỳ tốn tài nguyên CPU/RAM/IOPS trên Cloud SQL (crash-consistent cho Postgres), vẫn có thể ảnh hưởng shared resources. Data scientists đọc từ clone riêng nhưng lag cao, không scalable cho báo cáo lớn (vẫn RDBMS OLTP-style). Không hiệu quả bằng CDC streaming.

🏆 Kết luận: Giải pháp Datastream + BigQuery là optimal, managed, low-latency theo GCP best practices 2026! 🚀

Câu 298
You are developing a web application by using Cloud Run and Cloud Storage. You are notified of a production issue that you need to troubleshoot immediately. You need to implement a workaround that requires you to execute a script on a Git repository. Your corporate laptop is unavailable but you have your personal computer. You can use your corporate credentials to access the required Git repository and Google Cloud resources. You want to fix the issue as quickly and efficiently as possible while minimizing additional cost. What should you do?
  1. A Create and launch a workstation with Cloud Workstations on your personal computer. Authenticate and set up API access in the workstation. Clone the Git repository and execute the workaround script. Ensure that the issue has been fixed.
  2. B Install VS Code and the extension Cloud Code for VS Code on your personal computer. Check the Cloud Run logs in Cloud Code to confirm the error. Execute the workaround script. Ensure that the issue has been fixed.
  3. C Connect to the Google Cloud console and open Cloud Shell on your personal computer. Clone the Git repository and execute the workaround script. Ensure that the issue has been fixed.
  4. D Download and install the gcloud CLI on your personal computer. Authenticate and set up API access. Clone the Git repository and execute the workaround script. Ensure that the issue has been fixed.
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 phát triển ứng dụng web trên Google Cloud Platform (GCP), sử dụng Cloud Run (dịch vụ serverless cho container) và Cloud Storage (lưu trữ object). Bạn đang gặp vấn đề production khẩn cấp cần troubleshoot ngay lập tức, và cần triển khai workaround bằng cách chạy một script từ Git repository.

🔑 Ràng buộc chính:

  • Laptop công ty không khả dụng, chỉ dùng personal computer.
  • Có corporate credentials để truy cập Git repo và GCP resources.
  • Ưu tiên: Nhanh nhất, hiệu quả nhất, minimize chi phí thêm.

Mục tiêu là chọn cách truy cập nhanh GCP tools, clone Git và chạy script mà không cần install phần mềm nặng, không tốn phí, và an toàn với credentials. Đây là câu hỏi kiểm tra kiến thức về các công cụ phát triển nhanh trên GCP như Cloud Shell (dựa trên phiên bản mới nhất GCP 2024-2026, Cloud Shell vẫn là lựa chọn ephemeral browser-based miễn phí với tools pre-installed).

📘 Tài liệu tham khảo:

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Connect to the Google Cloud console and open Cloud Shell on your personal computer. Clone the Git repository and execute the workaround script. Ensure that the issue has been fixed.

Lý do 🛠️:

  • Nhanh nhất: Chỉ cần mở browser truy cập Google Cloud Console (console.cloud.google.com), click Cloud Shell (Activate Cloud Shell) – mất <1 phút, không cần install gì trên personal computer.
  • Hiệu quả: Cloud Shell có sẵn gcloud CLI, Git, Docker, VS Code tích hợp, hỗ trợ corporate credentials qua OAuth. Clone Git (git clone), chạy script, troubleshoot Cloud Run/Storage trực tiếp (xem logs, deploy).
  • Minimize cost: Miễn phí hoàn toàn (5GB storage persistent, session 1h auto-suspend, không tính phí compute trừ khi dùng nặng).
  • Phù hợp production urgent: Browser-based, ephemeral (dữ liệu session reset nhưng persistent disk giữ code), cập nhật 2026 vẫn là best practice cho quick fixes.

📋 Giải thích tất cả các phương án (đúng/sai)

  • ❌ [SAI] Create and launch a workstation with Cloud Workstations on your personal computer. Authenticate and set up API access in the workstation. Clone the Git repository and execute the workaround script. Ensure that the issue has been fixed.
    Giải thích sai: Cloud Workstations (ra mắt 2023, cập nhật 2025) là VM-based dev environment mạnh mẽ, nhưng chậm khởi tạo (5-10 phút tạo cluster/workstation), tốn phí (compute VM ~$0.1/giờ+), và cần setup API access phức tạp. Không phù hợp "immediately" và "minimize cost" – quá mức cần cho script đơn giản.

  • ❌ [SAI] Install VS Code and the extension Cloud Code for VS Code on your personal computer. Check the Cloud Run logs in Cloud Code to confirm the error. Execute the workaround script. Ensure that the issue has been fixed.
    Giải thích sai: Cần install VS Code + Cloud Code extension (tải ~500MB+, thời gian 10-20 phút), sau đó authenticate riêng. Tuy hỗ trợ logs Cloud Run tốt, nhưng không nhanh cho urgent fix, và không tự động có Git/tools đầy đủ như Cloud Shell. Phù hợp dev dài hạn, không phải workaround khẩn.

  • ✅ [ĐÚNG] Connect to the Google Cloud console and open Cloud Shell on your personal computer. Clone the Git repository and execute the workaround script. Ensure that the issue has been fixed.
    Giải thích đúng: Như phần trên – tối ưu nhất cho tốc độ (browser-only), tools sẵn (gcloud run services logs, gsutil cho Storage), credentials seamless, zero install/zero cost thêm. Best practice GCP cho troubleshooting production (xác nhận qua Google Cloud Skills Boost exams 2025).

  • ❌ [SAI] Download and install the gcloud CLI on your personal computer. Authenticate and set up API access. Clone the Git repository and execute the workaround script. Ensure that the issue has been fixed.
    Giải thích sai: Phải download gcloud SDK (~250MB, install 5-15 phút), setup PATH/API keys, authenticate (gcloud auth login). Chậm hơn Cloud Shell (cần personal machine config), tiềm ẩn issue firewall/proxy trên personal PC, và không miễn phí nếu dùng heavy (nhưng chủ yếu chậm + phức tạp).

Kết luận 🎯: Cloud Shell là "Swiss Army knife" cho GCP devs – nhanh, free, powerful cho urgent tasks! Nếu cần scale, mới dùng Workstations/CLI.

Câu 299
You are using App Engine and Cloud SQL for PostgreSQL to develop an application. You want to test your application code locally before deploying new application versions to the development environment that is shared with other developers. You need to set up your App Engine local development environment to test your application while keeping all traffic to Cloud SQL instances encrypted and authenticated to Cloud IAM and PostgreSQL. What should you do before starting the local development server?
  1. A Install PostgreSQL on your local workstation. Run a local PostgreSQL database on your workstation. Configure the application to connect to a PostgreSQL instance on localhost.
  2. B Download and install the Cloud SQL Auth Proxy to your local development environment. Configure the Cloud SQL Auth Proxy to connect to the Cloud SQL instance and run the proxy. Configure the application to connect to a PostgreSQL instance on localhost.
  3. C Deploy a Compute Engine instance, and install HAProxy on the instance. Configure Cloud SQL Auth Proxy on the instance, and use the instance’s service account to authenticate to Cloud SQL. Configure the application to connect to the Compute Engine instance's IP address.
  4. D Configure your local development server to connect to the private IP address of the Cloud SQL instance. Encrypt database entries with a cryptographic library before submitting them to the database. Store the decryption key as an environment variable in App Engine.
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 thiết lập môi trường phát triển cục bộ (local development environment) cho ứng dụng App Engine sử dụng Cloud SQL for PostgreSQL trên Google Cloud Platform (GCP). Mục tiêu là test code ứng dụng locally trước khi deploy lên môi trường development chia sẻ, đồng thời đảm bảo tất cả traffic đến Cloud SQL được mã hóa (encrypted) và xác thực (authenticated) qua Cloud IAM và PostgreSQL.

  • Bối cảnh: App Engine standard/flex hỗ trợ dev local qua công cụ như dev_appserver.py. Tuy nhiên, Cloud SQL yêu cầu kết nối an toàn, không expose trực tiếp, đặc biệt với IAM database authentication (từ năm 2021+ được khuyến nghị thay thế static passwords).
  • Yêu cầu chính: Trước khi chạy local dev server, cần cấu hình để app local connect đến Cloud SQL thật (không phải local DB), giữ nguyên encryption (SSL/TLS) và auth qua IAM service account.
  • Phiên bản cập nhật 2026: Theo docs GCP mới nhất (Cloud SQL v2024+), Cloud SQL Auth Proxy là phương pháp chuẩn cho local dev, hỗ trợ IAM auth, automatic encryption, và TCP proxying (không cần VPC peering cho local).

📘 Tài liệu tham khảo:

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Download and install the Cloud SQL Auth Proxy to your local development environment. Configure the Cloud SQL Auth Proxy to connect to the Cloud SQL instance and run the proxy. Configure the application to connect to a PostgreSQL instance on localhost.

Lý do 🛠️:

  • Cloud SQL Auth Proxy là công cụ chính thức của GCP để proxy kết nối local → Cloud SQL, sử dụng IAM service account để auth (không cần password), tự động encrypt traffic qua SSL/TLS.
  • App local connect qua localhost:5432 (proxy port), simulate production mà không expose Cloud SQL public IP/private IP.
  • Hoàn hảo cho App Engine local dev server (dev_appserver.py), test real DB mà giữ an toàn. Hỗ trợ PostgreSQL đầy đủ (v15+ năm 2026).

📋 Giải thích chi tiết tất cả các phương án

Dưới đây là phân tích từng lựa chọn, giữ nguyên văn bản gốc tiếng Anh. Mỗi phương án được đánh giá ✅ (đúng) hoặc ❌ (sai), kèm lý do cụ thể bằng tiếng Việt:

  • ❌ [SAI] Install PostgreSQL on your local workstation. Run a local PostgreSQL database on your workstation. Configure the application to connect to a PostgreSQL instance on localhost.
    Lý do sai: Phương án này dùng local PostgreSQL giả lập, không kết nối đến Cloud SQL thật, nên không test được hành vi production (như IAM auth, Cloud SQL features như read replicas, automatic backups). Không đảm bảo encryption/auth với Cloud IAM/PostgreSQL, chỉ là DB local thuần túy. Không phù hợp yêu cầu "keeping all traffic to Cloud SQL instances encrypted and authenticated".

  • ✅ [ĐÚNG] Download and install the Cloud SQL Auth Proxy to your local development environment. Configure the Cloud SQL Auth Proxy to connect to the Cloud SQL instance and run the proxy. Configure the application to connect to a PostgreSQL instance on localhost.
    Lý do đúng: Như đã giải thích ở trên 🛠️. Proxy chạy local (./cloud_sql_proxy -instances=project:region:instance=tcp:5432), app dùng host=127.0.0.1 port=5432, auth qua gcloud auth application-default login hoặc service account key. Đầy đủ encryption (mTLS), IAM auth, và chỉ forward traffic cần thiết.

  • ❌ [SAI] Deploy a Compute Engine instance, and install HAProxy on the instance. Configure Cloud SQL Auth Proxy on the instance, and use the instance’s service account to authenticate to Cloud SQL. Configure the application to connect to the Compute Engine instance's IP address.
    Lý do sai: Quá phức tạp và tốn kém cho local dev (deploy VM + HAProxy làm gì?). Local app connect qua public IP của CE, thêm latency, không trực tiếp/nhanh như proxy local. Không cần thiết vì proxy có thể chạy thẳng trên workstation. HAProxy chỉ dùng cho load balancing production, không phải local testing.

  • ❌ [SAI] Configure your local development server to connect to the private IP address of the Cloud SQL instance. Encrypt database entries with a cryptographic library before submitting them to the database. Store the decryption key as an environment variable in App Engine.
    Lý do sai: Local workstation không access được private IP của Cloud SQL (chỉ trong VPC, cần VPC peering/VPN phức tạp). Encryption app-level (cryptographic library) không thay thế transport encryption (SSL), và không dùng Cloud IAM auth. Lưu key ở env App Engine là cho production, không liên quan local dev. Rủi ro bảo mật cao nếu expose private IP.

🔍 Kết luận: Phương án đúng duy nhất đảm bảo an toàn, đơn giản, và test real Cloud SQL cho App Engine local dev! Nếu cần code sample, tham khảo docs GCP chính thức.

Câu 300
You are developing a public web application on Cloud Run. You expose the Cloud Run service directly with its public IP address. You are now running a load test to ensure that your application is resilient against high traffic loads. You notice that your application performs as expected when you initiate light traffic. However, when you generate high loads, your web server runs slowly and returns error messages. How should you troubleshoot this issue?
  1. A Check the network traffic to Cloud Run in Cloud Monitoring to validate whether a traffic spike occurred. If necessary, enable traffic splitting on the Cloud Run instance to route some of the traffic to a previous instance revision.
  2. B Check the min-instances value for your Cloud Run service. If necessary, increase the min-instances value to match the maximum number of virtual users in your load test.
  3. C Check whether Cloud Armor is detecting distributed denial of service (DDoS) attacks and is blocking traffic before the traffic is routed to your Cloud Run service. If necessary, disable any Cloud Armor policies in your project.
  4. D Check whether the Cloud Run service has scaled to a number of instances that equals the max-instances value. If necessary, increase the max-instances value.
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 phát triển một ứng dụng web công khai trên Cloud Run (dịch vụ serverless của Google Cloud). Ứng dụng được expose trực tiếp qua địa chỉ IP công khai của Cloud Run. Khi chạy load test (kiểm tra tải):

  • Giao thông nhẹ (light traffic): Ứng dụng hoạt động bình thường ✅.
  • Tải cao (high loads): Web server chạy chậm và trả về lỗi ❌.

Vấn đề cốt lõi: Cần troubleshoot (khắc phục sự cố) để đảm bảo ứng dụng chịu tải cao. Cloud Run tự động scale (mở rộng) số lượng instances dựa trên lưu lượng, nhưng có giới hạn max-instances (số instances tối đa). Khi đạt giới hạn này, request sẽ bị queue (xếp hàng) hoặc từ chối, dẫn đến chậm/lỗi. Load test giả lập traffic spike, nên cần kiểm tra scaling behavior theo tài liệu mới nhất Google Cloud (cập nhật 2024-2026).

📘 Nguồn tham khảo:

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Check whether the Cloud Run service has scaled to a number of instances that equals the max-instances value. If necessary, increase the max-instances value.

Lý do 🛠️:

  • Cloud Run scale tự động từ 0 (hoặc min-instances) lên đến max-instances dựa trên concurrency (số request đồng thời). Khi tải cao từ load test, nếu đạt max-instances, hệ thống không scale thêm → request bị throttle (hạn chế), gây chậm/lỗi.
  • Giải pháp: Kiểm tra metrics trong Cloud Monitoring (số instances hiện tại so với max-instances). Nếu cần, tăng max-instances (mặc định 1000, có thể lên hàng nghìn tùy quota).
  • Đây là nguyên nhân phổ biến nhất cho vấn đề "light OK, high NG" trên Cloud Run serverless.

📋 Giải thích tất cả các phương án (đúng/sai)

  • ❌ [SAI] Check the network traffic to Cloud Run in Cloud Monitoring to validate whether a traffic spike occurred. If necessary, enable traffic splitting on the Cloud Run instance to route some of the traffic to a previous instance revision.
    Giải thích sai: Kiểm tra traffic spike trong Monitoring là tốt, nhưng traffic splitting dùng cho canary deployments (phân luồng traffic giữa revisions mới/cũ), không giải quyết scale under load. Load test là traffic hợp pháp, không cần split → không khắc phục chậm/lỗi.

  • ❌ [SAI] Check the min-instances value for your Cloud Run service. If necessary, increase the min-instances value to match the maximum number of virtual users in your load test.
    Giải thích sai: Min-instances giữ instances luôn chạy để tránh cold starts (khởi động chậm lần đầu). Vấn đề xảy ra ở high load (không phải cold start), tăng min-instances chỉ tốn chi phí mà không giúp scale-out khi overload. Không liên quan đến số virtual users.

  • ❌ [SAI] Check whether Cloud Armor is detecting distributed denial of service (DDoS) attacks and is blocking traffic before the traffic is routed to your Cloud Run service. If necessary, disable any Cloud Armor policies in your project.
    Giải thích sai: Cloud Armor bảo vệ DDoS/threat, nhưng load test là traffic hợp pháp từ công cụ kiểm tra (không phải attack). Disable policy nguy hiểm (mở cửa cho real DDoS). Cloud Run không cần Cloud Armor mặc định cho public IP → không phải nguyên nhân.

  • ✅ [ĐÚNG] Check whether the Cloud Run service has scaled to a number of instances that equals the max-instances value. If necessary, increase the max-instances value.
    Giải thích đúng (như phần trên): Trực tiếp nhắm vào giới hạn scale chính của Cloud Run. Metrics trong Monitoring/Logs xác nhận nhanh chóng. Tăng max-instances giải quyết ngay (quota cho phép lên 1000+ theo cập nhật 2024).

Khuyến nghị thêm 🚀: Sau fix, theo dõi concurrency (mặc định 80 request/instance) và quota project để tránh quota exhaustion. Sử dụng gcloud run services describe kiểm tra config!