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

Tìm thấy 358 câu.

Câu 271
You are a developer at a social media company. The company runs their social media website on-premises and uses MySQL as a backend to store user profiles and user posts. Your company plans to migrate to Google Cloud, and your learn will migrate user profile information to Firestore. You are tasked with designing the Firestore collections. What should you do?
  1. A Create one root collection for user profiles, and create one root collection for user posts.
  2. B Create one root collection for user profiles, and create one subcollection for each user's posts.
  3. C Create one root collection for user profiles, and store each user's post as a nested list in the user profile document.
  4. D Create one root collection for user posts, and create one subcollection for each user's profile.
Xem giải thích

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

Câu hỏi mô tả tình huống một công ty mạng xã hội đang chạy website trên on-premises với backend MySQL lưu trữ user profiles (hồ sơ người dùng) và user posts (bài đăng của người dùng). Công ty đang migrate sang Google Cloud, cụ thể migrate dữ liệu user profiles sang Firestore (một NoSQL document database của Google Cloud). Nhiệm vụ của bạn là thiết kế cấu trúc collections trong Firestore để lưu trữ dữ liệu này một cách tối ưu.

📌 Mục tiêu chính: Thiết kế mô hình dữ liệu Firestore phù hợp với đặc thù của ứng dụng mạng xã hội, nơi cần truy vấn nhanh hồ sơ người dùng và bài đăng của từng người dùng riêng biệt, hỗ trợ scale lớn, tránh hot-spotting (tập trung truy cập vào một document), và tuân thủ best practices của Firestore (cập nhật đến 2026: Firestore hỗ trợ hierarchical data model với root collections và subcollections, giới hạn document size 1MB, index tự động cho subcollections).

🛠️ Lý do cần thiết kế cẩn thận: Firestore không phải relational DB như MySQL, nên cần tránh denormalization quá mức (nested arrays/lists lớn gây vượt giới hạn), ưu tiên subcollections để phân tán truy cập và dễ query (ví dụ: lấy tất cả posts của một user mà không scan toàn bộ collection).

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

Đáp án đúng: Create one root collection for user profiles, and create one subcollection for each user's posts.

Lý do 🏆:

  • Đây là best practice chuẩn của Firestore cho mô hình 1:N (một user có nhiều posts). Root collection users lưu profiles (document ID là user ID), mỗi user document có subcollection posts riêng → Truy vấn hiệu quả (query chỉ subcollection của user cụ thể, tránh scan lớn), scale tốt (phân tán writes/reads), hỗ trợ fan-out real-time updates.
  • Tuân thủ Firestore data model (hierarchical), giảm chi phí query và tránh giới hạn 1MB/document. Phù hợp migrate từ MySQL (profiles → documents, posts → subcollection rows).

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

  • ✅ Create one root collection for user profiles, and create one subcollection for each user's posts.
    Giải thích đúng 🎯: Như trên, mô hình lý tưởng cho ứng dụng social media. Dễ query "tất cả posts của user X" qua users/{userId}/posts, hỗ trợ pagination, security rules granular (chỉ user đọc posts của mình). Best practice từ docs chính thức, scale đến hàng triệu users/posts.

  • ❌ Create one root collection for user profiles, and create one root collection for user posts.
    Giải thích sai 🚫: Tạo hai root collections riêng biệt (users và posts) làm khó liên kết dữ liệu. Để lấy posts của user cụ thể, phải query toàn bộ posts collection với filter userId → Gây hot-spotting nếu user phổ biến (nhiều reads/writes), chi phí cao, kém hiệu quả so với subcollections. Không khuyến khích cho 1:N relationships.

  • ❌ Create one root collection for user profiles, and store each user's post as a nested list in the user profile document.
    Giải thích sai ❌: Lưu posts dưới dạng array/list nested trong document user profile vi phạm giới hạn 1MB/document (posts có thể vượt nhanh với text/media). Không thể query/index sâu vào array (khó tìm post theo thời gian/tag), kém real-time sync, và writes atomic lớn gây contention. Chỉ phù hợp dữ liệu nhỏ, không scale cho social posts.

  • ❌ Create one root collection for user posts, and create one subcollection for each user's profile.
    Giải thích sai 🔄: Đảo ngược logic! Root posts với subcollection profiles per post không hợp lý (một post không "sở hữu" profile, mà profile sở hữu nhiều posts). Dẫn đến dữ liệu duplicate (profile lặp ở nhiều subcollections), query profiles khó (phải aggregate từ nhiều nơi), vi phạm normalization và tăng storage cost. Hoàn toàn ngược best practices.

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

Hy vọng phân tích này giúp bạn nắm vững thiết kế Firestore! 🚀 Nếu cần ví dụ code/schema, hãy hỏi thêm nhé!

Câu 272
Your team recently deployed an application on Google Kubernetes Engine (GKE). You are monitoring your application and want to be alerted when the average memory consumption of your containers is under 20% or above 80%. How should you configure the alerts?
  1. A Create a Cloud Function that consumes the Monitoring API. Create a schedule to trigger the Cloud Function hourly and alert you if the average memory consumption is outside the defined range.
  2. B In Cloud Monitoring, create an alerting policy to notify you if the average memory consumption is outside the defined range.
  3. C Create a Cloud Function that runs on a schedule, executes kubectl top on all the workloads on the cluster, and sends an email alert if the average memory consumption is outside the defined range.
  4. D Write a script that pulls the memory consumption of the instance at the OS level and sends an email alert if the average memory consumption is outside the defined range.
Xem giải thích

🧩 Giải thích nội dung câu hỏi

Câu hỏi tập trung vào việc giám sát và thiết lập cảnh báo (alerting) cho ứng dụng chạy trên Google Kubernetes Engine (GKE) – một dịch vụ quản lý Kubernetes của Google Cloud. Cụ thể, bạn cần theo dõi mức tiêu thụ bộ nhớ trung bình (average memory consumption) của các container trong cluster GKE, và kích hoạt thông báo khi giá trị này dưới 20% hoặc trên 80%.

Mục tiêu là chọn phương pháp tối ưu, tự động hóa cao, sử dụng công cụ native của Google Cloud để xử lý metrics (chỉ số đo lường) thời gian thực từ container, thay vì các cách thủ công hoặc không scale. Cloud Monitoring (trước đây là Stackdriver) là dịch vụ chính để thu thập metrics từ GKE, bao gồm container_memory_usage_bytes và container_memory_utilization, hỗ trợ alerting dựa trên ngưỡng (threshold) với điều kiện "outside the range" (ngoài khoảng 20-80%).

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

Đáp án đúng: In Cloud Monitoring, create an alerting policy to notify you if the average memory consumption is outside the defined range.

Lý do:

  • 🛠️ Đây là cách chuẩn và được khuyến nghị bởi Google Cloud (cập nhật đến 2026). Cloud Monitoring tự động thu thập metrics chi tiết từ GKE containers (như kubernetes.io/container/memory/utilization), hỗ trợ tạo alerting policy với điều kiện ngưỡng kép (under 20% OR over 80%), sử dụng aggregation (average) qua thời gian (ví dụ: 5 phút).
  • 📈 Alert sẽ kích hoạt thông báo real-time qua email, Slack, PagerDuty, hoặc các kênh khác, không cần code thủ công, scale tốt cho nhiều workload.
  • 🚀 Hiệu quả cao, chi phí thấp, tích hợp native với GKE mà không cần tool bên thứ ba.

📋 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 bằng tiếng Anh. Tôi đánh dấu ✅ cho đúng và ❌ cho sai, kèm lý do cụ thể dựa trên best practices Google Cloud (phiên bản mới nhất 2026).

  • ❌ [SAI] Create a Cloud Function that consumes the Monitoring API. Create a schedule to trigger the Cloud Function hourly and alert you if the average memory consumption is outside the defined range.
    Giải thích sai: Phương án này không real-time (chỉ chạy hàng giờ qua Cloud Scheduler), dễ miss sự cố ngắn hạn. Cloud Functions + Monitoring API có thể query metrics, nhưng phức tạp hóa không cần thiết khi Cloud Monitoring đã có alerting policy built-in. Không scale tốt, tốn chi phí invoke lặp lại, vi phạm nguyên tắc "use managed services" của GCP.

  • ✅ [ĐÚNG] In Cloud Monitoring, create an alerting policy to notify you if the average memory consumption is outside the defined range.
    Giải thích đúng: Như đã nêu ở phần trên, đây là giải pháp native, tự động, chính xác với metrics GKE-specific (e.g., container/memory/utilization). Hỗ trợ MQL (Monitoring Query Language) cho điều kiện phức tạp như "average > 80% OR < 20%", alerting ngay lập tức (dưới 1 phút), và dễ quản lý qua Console/UI hoặc Terraform.

  • ❌ [SAI] Create a Cloud Function that runs on a schedule, executes kubectl top on all the workloads on the cluster, and sends an email alert if the average memory consumption is outside the defined range.
    Giải thích sai: Không khuyến nghị và không scale. kubectl top chỉ cung cấp snapshot thủ công (dựa trên Heapster/cAdvisor), không phải metrics chính xác/aggregation từ Cloud Monitoring. Cloud Function chạy schedule cần quyền cluster-admin (rủi ro bảo mật), chậm với cluster lớn, và email thủ công thay vì alerting policy chuyên dụng. GKE Autopilot (2026) thậm chí hạn chế exec commands.

  • ❌ [SAI] Write a script that pulls the memory consumption of the instance at a OS level and sends an email alert if the average memory consumption is outside the defined range.
    Giải thích sai: Hoàn toàn sai ngữ cảnh vì chỉ pull metrics node/instance OS-level (e.g., vm.memory.usage), không phải container-level trong GKE. Không phân biệt workload cụ thể, thiếu aggregation average, và script thủ công (chạy cron?) không tích hợp với Cloud Monitoring. Dễ lỗi, không hỗ trợ alerting đa kênh, vi phạm nguyên tắc observability của GCP.

📘 Tài liệu tham khảo

Hy vọng phân tích này giúp bạn ôn tập hiệu quả! 🚀 Nếu cần ví dụ code Terraform cho alerting policy, hãy hỏi thêm.

Câu 273
You manage a microservice-based ecommerce platform on Google Cloud that sends confirmation emails to a third-party email service provider using a Cloud Function. Your company just launched a marketing campaign, and some customers are reporting that they have not received order confirmation emails. You discover that the services triggering the Cloud Function are receiving HTTP 500 errors. You need to change the way emails are handled to minimize email loss. What should you do?
  1. A Increase the Cloud Function's timeout to nine minutes.
  2. B Configure the sender application to publish the outgoing emails in a message to a Pub/Sub topic. Update the Cloud Function configuration to consume the Pub/Sub queue.
  3. C Configure the sender application to write emails to Memorystore and then trigger the Cloud Function. When the function is triggered, it reads the email details from Memorystore and sends them to the email service.
  4. D Configure the sender application to retry the execution of the Cloud Function every one second if a request fails.
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 nền tảng thương mại điện tử dựa trên microservice chạy trên Google Cloud, sử dụng Cloud Function để gửi email xác nhận đơn hàng đến nhà cung cấp dịch vụ email bên thứ ba (third-party email service provider).
🚨 Vấn đề chính: Sau chiến dịch marketing lớn, một số khách hàng không nhận được email xác nhận. Nguyên nhân là các dịch vụ kích hoạt Cloud Function gặp HTTP 500 errors (lỗi server nội bộ).
🎯 Yêu cầu giải quyết: Thay đổi cách xử lý email để giảm thiểu mất mát email (minimize email loss), đảm bảo độ tin cậy cao hơn, tránh tình trạng function fail dẫn đến mất dữ liệu email.

Bối cảnh kỹ thuật (cập nhật đến 2026): Cloud Function (phiên bản 2nd gen) thường được trigger qua HTTP, dễ fail nếu third-party overload (như 500 errors). Giải pháp cần decouple (tách rời) để sử dụng message queue với retry tự động, phù hợp với best practices Google Cloud cho event-driven architecture.

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

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

Đáp án đúng: Configure the sender application to publish the outgoing emails in a message to a Pub/Sub topic. Update the Cloud Function configuration to consume the Pub/Sub queue.

Lý do chi tiết:
🛠️ Phương án này decouple hoàn toàn sender (ứng dụng gửi email) khỏi Cloud Function bằng Pub/Sub làm message broker. Sender chỉ publish message chứa email vào Pub/Sub topic (at-least-once delivery). Cloud Function được config trigger từ Pub/Sub (event-driven), tự động retry nếu fail (lên đến 7 ngày theo default policy 2026). Nếu vẫn fail, message đi vào dead letter queue để xử lý sau, minimize email loss tối đa.
🔥 Không còn HTTP 500 trực tiếp từ third-party overload, scale dễ dàng (Pub/Sub auto-scale đến hàng triệu message/giây). Đây là best practice cho microservices trên Google Cloud, giảm coupling và tăng resilience.

❌ Phân tích tất cả các phương án (đúng/sai)

  • [SAI] Increase the Cloud Function's timeout to nine minutes.
    ❌ Sai vì: Chỉ tăng timeout (max 60 phút ở 2nd gen) không giải quyết root cause HTTP 500 từ third-party (có thể do rate limit hoặc outage kéo dài). Email vẫn mất nếu function exceed timeout hoặc retry fail. Không decouple, vẫn dễ overload. Không phải giải pháp bền vững cho high-volume campaign.

  • [ĐÚNG] Configure the sender application to publish the outgoing emails in a message to a Pub/Sub topic. Update the Cloud Function configuration to consume the Pub/Sub queue.
    ✅ Đúng vì: Như giải thích trên, sử dụng Pub/Sub làm queue asynchronous với built-in retry (exponential backoff), dead letter queue, và exactly-once delivery (nếu config idempotent). Hoàn hảo để minimize loss, scale tự động, phù hợp Google Cloud best practices 2026.

  • [SAI] Configure the sender application to write emails to Memorystore and then trigger the Cloud Function. When the function is triggered, it reads the email details from Memorystore and sends them to the email service.
    ❌ Sai vì: Memorystore (Redis) chỉ là in-memory cache, không bền vững (dữ liệu mất nếu node fail, TTL expire). Vẫn dùng HTTP trigger cho Function → vẫn gặp 500 errors. Không có retry tự động như Pub/Sub, phức tạp hơn, và chi phí cao cho persistence (nên dùng Firestore/Spanner thay thế). Không minimize loss hiệu quả.

  • [SAI] Configure the sender application to retry the execution of the Cloud Function every one second if a request fails.
    ❌ Sai vì: Retry synchronous every 1s gây throttle/hotspot (Cloud Function quota 1.000 invocation/phút default), làm tình hình tệ hơn (hàng nghìn retry → quota exceed, chi phí tăng vọt). Không decouple, không có backoff policy thông minh, dễ DDoS third-party. Không scale cho campaign lớn.

Kết luận 🎉: Chọn Pub/Sub là giải pháp resilient nhất, tuân thủ nguyên tắc idempotency + async processing trong Google Cloud serverless (2026 updates nhấn mạnh Pub/Sub cho event sourcing). Nếu implement, test với load testing tools như Artillery!

Câu 274
You have a web application that publishes messages to Pub/Sub. You plan to build new versions of the application locally and need to quickly test Pub/Sub integration for each new build. How should you configure local testing?
  1. A In the Google Cloud console, navigate to the API Library, and enable the Pub/Sub API. When developing locally configure your application to call pubsub.googleapis.com.
  2. B Install the Pub/Sub emulator using gcloud, and start the emulator with a valid Google Project ID. When developing locally, configure your applicat.cn to use the local emulator by exporting the PUBSUB_EMULATOR_HOST variable.
  3. C Run the gcloud config set api_endpoint_overrides/pubsub https://pubsubemulator.googleapis.com.com/ command to change the Pub/Sub endpoint prior to starting the application.
  4. D Install Cloud Code on the integrated development environment (IDE). Navigate to Cloud APIs, and enable Pub/Sub against a valid Google Project IWhen developing locally, configure your application to call pubsub.googleapis.com.
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 cấu hình kiểm thử cục bộ (local testing) cho một ứng dụng web sử dụng Google Cloud Pub/Sub để publish messages. Bạn đang phát triển các phiên bản mới của ứng dụng trên máy local và cần kiểm tra nhanh chóng tích hợp Pub/Sub mà không phụ thuộc vào môi trường cloud thực tế.

  • Bối cảnh chính: Pub/Sub là dịch vụ messaging quản lý của Google Cloud, dùng để gửi/nhận messages asynchronously. Để test local, cần tránh gọi API thật (pubsub.googleapis.com) vì tốn kém, chậm và cần project thật. Thay vào đó, sử dụng emulator (mô phỏng) để chạy cục bộ.
  • Mục tiêu: Cấu hình sao cho ứng dụng local có thể publish messages đến emulator Pub/Sub một cách nhanh chóng, an toàn.
  • Kiến thức cập nhật (2026): Theo tài liệu Google Cloud mới nhất (Pub/Sub Emulator v2.x), cách chuẩn là cài đặt emulator qua gcloud CLI, khởi động với project ID hợp lệ, và dùng biến môi trường PUBSUB_EMULATOR_HOST để redirect traffic local. Không có thay đổi lớn từ 2023-2026.

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

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

Đáp án đúng: Install the Pub/Sub emulator using gcloud, and start the emulator with a valid Google Project ID. When developing locally, configure your applicat.cn to use the local emulator by exporting the PUBSUB_EMULATOR_HOST variable.

Lý do 🛠️:

  • Đây là cách chuẩn và được khuyến nghị bởi Google Cloud để test Pub/Sub local.
    • Cài đặt: gcloud components install pubsub-emulator.
    • Khởi động: gcloud beta emulators pubsub start --project=your-project-id (emulator chạy trên localhost:8085).
    • Cấu hình app: Export PUBSUB_EMULATOR_HOST=localhost:8085 để client library (như google-cloud-pubsub) tự động dùng emulator thay vì production endpoint.
  • Ưu điểm: ✅ Nhanh, miễn phí, hỗ trợ đầy đủ features (topics, subscriptions, snapshots), và isolated khỏi cloud thật. Hoàn hảo cho CI/CD và dev local.

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

Dưới đây là phân tích từng phương án một cách chi tiết, 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 tính khả thi, tính chính xác và best practice của Google Cloud Pub/Sub Emulator (cập nhật 2026).

  • Phương án 1 (SAI): In the Google Cloud console, navigate to the API Library, and enable the Pub/Sub API. When developing locally configure your application to call pubsub.googleapis.com.
    ❌ Sai vì: Enable API trong console chỉ kích hoạt dịch vụ trên cloud project thật, không hỗ trợ local testing. Gọi pubsub.googleapis.com từ local sẽ hit production endpoint, gây tốn quota/billing, chậm (latency cao), và cần auth thật (service account). Không phù hợp "quick test" cho build mới.

  • Phương án 2 (ĐÚNG): Install the Pub/Sub emulator using gcloud, and start the emulator with a valid Google Project ID. When developing locally, configure your applicat.cn to use the local emulator by exporting the PUBSUB_EMULATOR_HOST variable.
    ✅ Đúng vì: Như giải thích ở phần đáp án đúng. Đây là workflow chính thức: emulator mimic toàn bộ API Pub/Sub local, dùng project ID để namespace topics/subscriptions. Biến PUBSUB_EMULATOR_HOST là key để client SDK tự detect và route traffic (hỗ trợ Java, Python, Node.js, Go...).

  • Phương án 3 (SAI): Run the gcloud config set api_endpoint_overrides/pubsub https://pubsubemulator.googleapis.com.com/ command to change the Pub/Sub endpoint prior to starting the application.
    ❌ Sai vì: Lệnh gcloud config set api_endpoint_overrides dùng để override endpoint cho gcloud CLI, không ảnh hưởng đến client library của app. Endpoint https://pubsubemulator.googleapis.com.com/ sai cú pháp (dấu .com thừa, không tồn tại). Không start emulator thật, nên app vẫn gọi production hoặc fail.

  • Phương án 4 (SAI): Install Cloud Code on the integrated development environment (IDE). Navigate to Cloud APIs, and enable Pub/Sub against a valid Google Project IWhen developing locally, configure your application to call pubsub.googleapis.com.
    ❌ Sai vì: Cloud Code (plugin VS Code/IntelliJ) hỗ trợ dev GCP nhưng chỉ giúp enable API trên project cloud thật, không cung cấp emulator local. Vẫn gọi pubsub.googleapis.com → giống phương án 1, không isolated cho local test. Thiếu "quick" vì phụ thuộc IDE và project thật.

Kết luận 🎯: Sử dụng Pub/Sub Emulator là best practice cho local dev, giúp iterate nhanh mà không rủi ro production. Nếu deploy, chuyển sang client production bằng cách unset biến môi trường!

Câu 275
You recently developed an application that monitors a large number of stock prices. You need to configure Pub/Sub to receive a high volume messages and update the current stock price in a single large in-memory database. A downstream service needs the most up-to-date prices in the in-memory database to perform stock trading transactions. Each message contains three pieces or information:
•Stock symbol
•Stock price
•Timestamp for the update

How should you set up your Pub/Sub subscription?
  1. A Create a pull subscription with exactly-once delivery enabled.
  2. B Create a push subscription with both ordering and exactly-once delivery turned off.
  3. C Create a push subscription with exactly-once delivery enabled.
  4. D Create a pull subscription with both ordering and exactly-once delivery turned off.
Xem giải thích

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

Câu hỏi này thuộc chủ đề Google Cloud Pub/Sub (không phải AWS như mô tả ban đầu, có thể là nhầm lẫn). Nó mô tả một ứng dụng giám sát giá cổ phiếu lớn, sử dụng Pub/Sub để nhận lượng lớn tin nhắn (high volume messages) chứa thông tin: Stock symbol, Stock price, và Timestamp. Các tin nhắn này cần cập nhật vào một cơ sở dữ liệu in-memory lớn duy nhất (single large in-memory database). Dịch vụ downstream yêu cầu giá cổ phiếu mới nhất (most up-to-date) để thực hiện giao dịch chứng khoán (stock trading transactions), đòi hỏi độ chính xác cao, tránh trùng lặp (duplicate) để ngăn chặn lỗi giao dịch.

Yêu cầu chính của subscription Pub/Sub:

  • Xử lý high volume tin nhắn nhanh chóng.
  • Đảm bảo exactly-once delivery (giao tin nhắn đúng một lần) vì cập nhật DB in-memory duy nhất – duplicate có thể gây sai lệch giá và mất tiền.
  • Không cần ordering nghiêm ngặt (vì timestamp đã có), nhưng ưu tiên độ tin cậy và throughput cao.
  • Pull subscription phù hợp hơn vì client tự kiểm soát việc pull và ack, hỗ trợ batching cho high volume và exactly-once (theo cập nhật GCP đến 2026).

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

✅ Đáp án đúng: Create a pull subscription with exactly-once delivery enabled.

Lý do lựa chọn 🛠️:

  • Pull subscription cho phép ứng dụng tự pull tin nhắn theo batch lớn, lý tưởng cho high volume (hàng triệu tin nhắn/giây), client kiểm soát ack để tránh overload DB in-memory.
  • Exactly-once delivery enabled đảm bảo mỗi tin nhắn được xử lý đúng 1 lần (dùng message ID và deduplication), tránh duplicate update giá cổ phiếu – rất quan trọng cho trading (downstream cần up-to-date chính xác).
  • Không cần ordering (ordering keys chỉ nếu thứ tự nghiêm ngặt, ở đây timestamp đủ dùng).
  • Push không hỗ trợ exactly-once đầy đủ (chỉ pull subscriptions hỗ trợ theo docs GCP mới nhất 2026), và push kém hiệu quả cho single DB vì endpoint có thể bị overwhelm.

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

  • Create a pull subscription with exactly-once delivery enabled.
    ✅ Đúng (như phân tích trên). Pull + exactly-once là combo tối ưu cho high volume, single DB, đảm bảo deduplication và up-to-date data. Hỗ trợ batch ack để scale.

  • Create a push subscription with both ordering and exactly-once delivery turned off.
    ❌ Sai. Push subscription không phù hợp high volume single DB vì Pub/Sub push liên tục đến endpoint (có thể gây overload in-memory DB). Tắt ordering/exactly-once dẫn đến at-least-once (có duplicate), rủi ro cao cho trading. Push không hỗ trợ exactly-once anyway.

  • Create a push subscription with exactly-once delivery enabled.
    ❌ Sai. Push không hỗ trợ exactly-once delivery (docs GCP xác nhận chỉ pull). Dù enable, vẫn rủi ro duplicate/replay nếu endpoint fail ack. Không lý tưởng cho high volume single DB (scale kém hơn pull).

  • Create a pull subscription with both ordering and exactly-once delivery turned off.
    ❌ Sai. Pull tốt cho high volume, nhưng tắt exactly-once chỉ cho at-least-once (duplicate có thể xảy ra, sai giá cổ phiếu). Tắt ordering không cần thiết nhưng không cứu vãn được thiếu deduplication – không an toàn cho downstream trading.

Kết luận 🎯: Lựa chọn pull + exactly-once đảm bảo độ tin cậy cao nhất cho kịch bản real-time trading trên GCP Pub/Sub (cập nhật 2026).

Câu 276 Chọn nhiều đáp án
Your team has created an application that is hosted on a Google Kubemetes Engine (GKE) cluster. You need to connect the application to a legacy REST service that is deployed in two GKE clusters in two different regions. You want to connect your application to the legacy service in a way that is resilient and requires the fewest number of steps. You also want to be able to run probe-based health checks on the legacy service on a separate port. How should you set up the connection? (Choose two.)
  1. A Use Traffic Director with a sidecar proxy to connect the application to the service.
  2. B Set up a proxyless Traffic Director configuration for the application.
  3. C Configure the legacy service's firewall to allow health checks originating from the sidecar proxy.
  4. D Configure the legacy service's firewall to allow health checks originating from the application.
  5. E Configure the legacy service's firewall to allow health checks originating from the Traffic Director control plane.
Xem giải thích

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

Câu hỏi này thuộc chủ đề Google Kubernetes Engine (GKE) và Traffic Director trong Google Cloud Platform (GCP). Tình huống: Đội ngũ đã triển khai một ứng dụng trên một GKE cluster. Ứng dụng cần kết nối với một legacy REST service được deploy trên hai GKE clusters ở hai regions khác nhau. Yêu cầu chính:

  • Kết nối phải resilient (bền vững, chịu lỗi cao, hỗ trợ multi-region).
  • Ít bước triển khai nhất (fewest number of steps).
  • Hỗ trợ probe-based health checks (kiểm tra sức khỏe dựa trên probe) trên port riêng biệt cho legacy service.

📌 Mục tiêu chọn hai phương án đúng: Sử dụng Traffic Director (dịch vụ control plane cho service mesh trong GCP) để quản lý traffic giữa các clusters/regions một cách tự động, resilient (load balancing, failover). Đây là giải pháp hybrid/multi-cluster tối ưu, không cần VPN hay peering phức tạp.

✅ Đáp án đúng (Chọn hai)

  • Use Traffic Director with a sidecar proxy to connect the application to the service.
    (Lý do: Đây là cách resilient nhất với ít bước, sử dụng sidecar proxy như Envoy để route traffic qua Traffic Director, hỗ trợ REST và health checks riêng biệt. Phù hợp multi-region GKE.)

  • Configure the legacy service's firewall to allow health checks originating from the sidecar proxy.
    (Lý do: Health probes từ sidecar proxy (Envoy) cần được phép qua firewall của legacy service trên port riêng, đảm bảo kiểm tra sức khỏe chính xác mà không ảnh hưởng traffic chính.)

🛠️ 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 dựa trên tài liệu GCP mới nhất (cập nhật đến 2026, Traffic Director hỗ trợ GKE 1.28+ với xDS v3, Envoy 1.29+ cho REST/HTTP):

  • ✅ Use Traffic Director with a sidecar proxy to connect the application to the service.
    Đúng 🏆: Traffic Director kết hợp sidecar proxy (Envoy injected vào pods) cho phép ứng dụng kết nối resilient đến legacy service multi-cluster/multi-region. Nó tự động load balance, failover, và hỗ trợ health checks trên port riêng (qua xDS config). Ít bước: Chỉ cần enable Traffic Director, annotate endpoints, inject proxy. Không cần thay đổi code ứng dụng. (Proxyless chỉ dành gRPC, không lý tưởng cho REST legacy).

  • ❌ Set up a proxyless Traffic Director configuration for the application.
    Sai 🚫: Proxyless Traffic Director chỉ hỗ trợ gRPC clients (qua gRPC name resolution), không phù hợp legacy REST service (HTTP/REST). Không resilient cho REST multi-region, thiếu sidecar để xử lý health checks port riêng và load balancing đầy đủ.

  • ✅ Configure the legacy service's firewall to allow health checks originating from the sidecar proxy.
    Đúng 🏆: Sidecar proxy (Envoy) gửi health probes từ IP của proxy pod, nên firewall legacy service phải mở port health check cụ thể cho nguồn từ proxy (thường VPC firewall rules hoặc GKE Network Policies). Đảm bảo probes hoạt động mà không expose port cho tất cả traffic.

  • ❌ Configure the legacy service's firewall to allow health checks originating from the application.
    Sai 🚫: Ứng dụng chính không gửi probes trực tiếp (qua sidecar), mà sidecar proxy làm việc đó. Mở firewall cho app trực tiếp kém resilient, dễ bị tấn công, và không tận dụng Traffic Director (cần proxy làm trung gian).

  • ❌ Configure the legacy service's firewall to allow health checks originating from the Traffic Director control plane.
    Sai 🚫: Traffic Director là control plane (chỉ push config xDS), không gửi probes trực tiếp. Probes đến từ data plane (sidecar proxy), nên mở firewall cho control plane (IP managed GCP) là sai và không an toàn.

📘 Tài liệu tham khảo (Cập nhật 2026)

Giải pháp này đảm bảo resilient, ít bước (chỉ config Traffic Director + firewall rules)! 🚀

Câu 277
You are monitoring a web application that is written in Go and deployed in Google Kubernetes Engine. You notice an increase in CPU and memory utilization. You need to determine which function is consuming the most CPU and memory resources. What should you do?
  1. A Add print commands to the application source code to log when each function is called, and redeploy the application.
  2. B Create a Cloud Logging query that gathers the web application s logs. Write a Python script that calculates the difference between the timestamps from the beginning and the end of the application's longest functions to identify time-intensive functions.
  3. C Import OpenTelemetry and Trace export packages into your application, and create the trace provider. Review the latency data for your application on the Trace overview page, and identify which functions cause the most latency.
  4. D Import the Cloud Profiler package into your application, and initialize the Profiler agent. Review the generated flame graph in the Google Cloud console to identify time-intensive functions.
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 giám sát và tối ưu hóa hiệu suất của một ứng dụng web được viết bằng ngôn ngữ Go, triển khai trên Google Kubernetes Engine (GKE). 👨‍💻 Bạn nhận thấy tăng đột biến CPU và memory utilization (sử dụng CPU và bộ nhớ), và cần xác định hàm (function) nào đang tiêu tốn nhiều tài nguyên CPU và memory nhất.

Mục tiêu chính là xác định các hàm "nóng" (hot spots) gây ra vấn đề, mà không chỉ dừng ở latency hay logging đơn giản. Đây là tình huống phổ biến trong performance profiling trên Google Cloud, nơi cần công cụ chuyên dụng để đo lường chính xác CPU time và memory allocation theo từng hàm. 🛠️ Câu hỏi kiểm tra kiến thức về các dịch vụ GCP như Cloud Profiler, Cloud Logging, và OpenTelemetry Tracing (cập nhật đến năm 2026, Cloud Profiler vẫn là công cụ chính cho CPU/memory profiling trên GKE với hỗ trợ Go native).

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

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

Đáp án đúng: Import the Cloud Profiler package into your application, and initialize the Profiler agent. Review the generated flame graph in the Google Cloud console to identify time-intensive functions.

Lý do:

  • 🏆 Cloud Profiler là dịch vụ chuyên dụng của Google Cloud để profile CPU, memory, và wall time theo từng hàm/line code một cách tự động, low-overhead (chi phí thấp ~1-2% CPU).
  • Với ứng dụng Go trên GKE, chỉ cần import package cloud.google.com/go/profiler và khởi tạo agent (ví dụ: profiler.Start()), profiler sẽ thu thập dữ liệu mà không cần thay đổi code lớn.
  • Flame graph trong Console hiển thị trực quan hot paths (các hàm tiêu tốn CPU/memory nhất), giúp pinpoint chính xác vấn đề. Đây là cách chuẩn và hiệu quả nhất cho continuous profiling trên production (hỗ trợ GKE agentless từ 2024+).
  • Không ảnh hưởng deploy lớn, scale tốt với Kubernetes. ✅

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

  • [SAI] Add print commands to the application source code to log when each function is called, and redeploy the application.
    ❌ Sai vì: Phương pháp thủ công này chỉ log thời điểm gọi hàm, không đo CPU/memory thực tế (không có metrics về thời lượng hay allocation). Redeploy liên tục gây downtime, không scale cho production. Overhead cao từ logging, không chính xác (race conditions trong Go). Không phải best practice cho profiling. 🐌

  • [SAI] Create a Cloud Logging query that gathers the web application s logs. Write a Python script that calculates the difference between the timestamps from the beginning and the end of the application's longest functions to identify time-intensive functions.
    ❌ Sai vì: Cloud Logging chỉ thu thập logs structured, không có dữ liệu CPU/memory chi tiết theo hàm. Phân tích timestamp thủ công bằng Python không đáng tin cậy (không đo CPU cycles hay heap allocation), dễ lỗi parsing, và không real-time. Overhead lớn từ log volume trên GKE, không phù hợp cho memory profiling. 📉

  • [SAI] Import OpenTelemetry and Trace export packages into your application, and create the trace provider. Review the latency data for your application on the Trace overview page, and identify which functions cause the most latency.
    ❌ Sai vì: OpenTelemetry/Cloud Trace đo latency và spans (thời gian end-to-end), không trực tiếp đo CPU/memory usage. Chỉ tốt cho distributed tracing, không có flame graph cho CPU hot spots hay memory leaks. Với Go, cần instrumentation manual nhiều, overhead cao hơn Profiler. Trace overview chỉ latency p50/p99, không pinpoint function-level resources. 🔍

Tóm lại, Cloud Profiler là lựa chọn tối ưu cho vấn đề CPU/memory trên GKE! 🚀 Nếu cần code sample Go, tôi có thể cung cấp thêm.

Câu 278
You are developing a flower ordering application. Currently you have three microservices:
•Order Service (receives the orders)
•Order Fulfillment Service (processes the orders)
•Notification Service (notifies the customer when the order is filled)

You need to determine how the services will communicate with each other. You want incoming orders to be processed quickly and you need to collect order information for fulfillment. You also want to make sure orders are not lost between your services and are able to communicate asynchronously. How should the requests be processed?
  1. A
  2. B
  3. C
  4. D
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 ứng dụng đặt hoa với ba microservices chính:

  • Order Service: Nhận đơn hàng từ khách hàng (incoming orders).
  • Order Fulfillment Service: Xử lý đơn hàng (processes the orders).
  • Notification Service: Thông báo cho khách hàng khi đơn hàng hoàn thành (notifies the customer).

Yêu cầu cốt lõi:

  • 📨 Xử lý đơn hàng nhanh chóng (processed quickly) để Order Service không bị nghẽn.
  • 💾 Thu thập thông tin đơn hàng để fulfillment (collect order information for fulfillment).
  • 🔒 Không mất đơn hàng giữa các service (orders are not lost between services).
  • ⚙️ Giao tiếp asynchronously (không đồng bộ, decoupling các service để tránh tight coupling).

Mục tiêu là thiết kế luồng xử lý requests giữa các service trên Google Kubernetes Engine (GKE), sử dụng các dịch vụ Google Cloud để đảm bảo độ tin cậy, tốc độ và tính không mất dữ liệu. Câu hỏi tập trung vào kiến trúc microservices với message queue để hỗ trợ async communication (cập nhật đến 2024-2026: Pub/Sub Lite và Enterprise hỗ trợ high-throughput messaging với durability cao). 🛠️

✅ Đáp án đúng: Phương án 4

Nội dung phương án (giữ nguyên tiếng Anh):
Order request → Order Service → Pub/Sub queue → Order Fulfillment Service → Firestore database → Pub/Sub queue → Notification Service

Lý do chọn đáp án này (hoàn toàn bằng tiếng Việt):
✅ Phương án này hoàn hảo phù hợp với tất cả yêu cầu:

  • Async communication: Order Service publish message vào Pub/Sub queue (durable message queue của Google Cloud), Fulfillment Service subscribe và xử lý độc lập → decoupling, không block Order Service, xử lý nhanh.
  • Không mất orders: Pub/Sub đảm bảo at-least-once delivery với retention lên đến 7 ngày (cập nhật 2026), dead letter queue tự động retry.
  • Collect info: Fulfillment lưu trạng thái vào Firestore (NoSQL database realtime), Notification đọc từ Firestore và Pub/Sub để notify.
  • Scalable trên GKE: Load Balancing phân tải, pods scale tự động.
    Phù hợp best practice microservices trên Google Cloud (Event-Driven Architecture). 🏆

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

❌ 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, giữ nguyên nội dung mô tả bằng tiếng Anh, chỉ giải thích đúng/sai bằng tiếng Việt. Sử dụng kiến thức Google Cloud mới nhất (Pub/Sub v2, Firestore v1.5+).

  • Phương án 1 (SAI):
    Nội dung phương án (giữ nguyên tiếng Anh):
    Order request → Order Service → Order Fulfillment Service → Notification Service
    (Synchronous chain qua Cloud Load Balancing → GKE Pods).

    ❌ Lý do sai: Đây là synchronous HTTP/gRPC calls trực tiếp giữa pods (Order → Fulfillment → Notification). Order Service bị block chờ Fulfillment hoàn thành → không nhanh (processed slowly nếu Fulfillment chậm). Tight coupling dễ mất orders nếu một pod crash (no durability). Không async, vi phạm yêu cầu chính. 🚫

  • Phương án 2 (SAI):
    Nội dung phương án (giữ nguyên tiếng Anh):
    Order request → Order Service → Cloud Storage bucket → Order Fulfillment Service → Cloud Storage bucket → Notification Service
    (Sử dụng Cloud Storage buckets làm intermediate storage).

    ❌ Lý do sai: Cloud Storage là object storage cho files, không phải message queue (polling-heavy, không realtime). Order Service phải write object → Fulfillment poll bucket → write lại → Notification poll → không async hiệu quả, tốn chi phí polling, dễ miss events nếu không cấu hình Notifications đúng (Object Lifecycle chỉ hỗ trợ delete, không queue). Không decoupling tốt, không quick processing. 🗑️

  • Phương án 3 (SAI):
    Nội dung phương án (giữ nguyên tiếng Anh):
    Order request → Order Service → Firestore database → Order Fulfillment Service → Firestore database → Notification Service
    (Shared Firestore database làm shared state).

    ❌ Lý do sai: Firestore là database realtime, nhưng dùng làm shared state tạo tight coupling (các service đọc/ghi cùng DB → contention cao, scalability kém). Không async thuần (cần polling changes hoặc listeners → Order Service vẫn chờ confirm write). Dễ mất orders nếu write fail mà không retry mechanism riêng. Không decoupling, vi phạm "communicate asynchronously". 📱

  • Phương án 4 (ĐÚNG): (Đã giải thích chi tiết ở trên) ✅

Kết luận: 🏁 Phương án Pub/Sub + Firestore là Event-Driven pattern chuẩn cho microservices trên Google Cloud, đảm bảo resilience và performance cao nhất! Nếu deploy thực tế, dùng Cloud Pub/Sub với GKE Autopilot cho scale tự động. 🚀

Câu 279
You recently deployed an application to GKE where Pods are writing files to a Compute Engine persistent disk. You have created a PersistentVolumeClaim (PVC) and a PersistentVolume (PV) object on Kubernetes for the disk, and you reference the PVC in the deployment manifest file.

You recently expanded the size of the persistent disk because the application has used up almost all of the disk space. You have logged on to one of the Pods, and you notice that the disk expansion is not visible in the container file system. What should you do?
  1. A Set the spec.capacity.storage value of the PV object to match the size of the persistent disk. Apply the updated configuration by using kubectl.
  2. B Recreate the application Pods by running the kubectl delete deployment DEPLOYMENT_NAME && kubectl apply deployment.yaml command, where the DEPLOYMENT_NAME parameter is the name of your deployment and deployment.yaml is its manifest file.
  3. C Set the spec.resources.requests.storage value of the PVC object to match the size of the persistent disk. Apply the updated configuration by using kubectl.
  4. D In the Pod, resize the disk partition to the maximum value by using the fdisk or parted utility.
Xem giải thích

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

Câu hỏi này xoay quanh tình huống trong Google Kubernetes Engine (GKE) trên Google Cloud Platform (GCP). Một ứng dụng đã được triển khai lên GKE, nơi các Pod đang ghi file vào một Compute Engine persistent disk (PD). Bạn đã tạo PersistentVolume (PV) và PersistentVolumeClaim (PVC) trên Kubernetes để quản lý đĩa này, và tham chiếu PVC trong file manifest của deployment.

Vấn đề chính: Bạn đã mở rộng kích thước của persistent disk (PD) vì ứng dụng gần hết dung lượng, nhưng khi đăng nhập vào một Pod, dung lượng mới không hiển thị trong file system của container.

Nguyên nhân gốc rễ (dựa trên tài liệu GCP cập nhật đến 2026):

  • Kubernetes không tự động nhận diện việc resize PD từ GCP. Bạn phải cập nhật PVC để kích hoạt volume expansion (mở rộng volume trực tuyến - online volume expansion).
  • GKE sử dụng PD CSI driver (từ GKE 1.23+, mặc định), hỗ trợ resize PD mà không cần unmount (nếu StorageClass có allowVolumeExpansion: true).
  • Sau khi update PVC, Kubernetes controller sẽ resize PV/PVC, và file system trong Pod sẽ được mở rộng tự động (hoặc thủ công bằng resize2fs nếu cần). Nếu không update PVC, Pod vẫn thấy dung lượng cũ.

Mục tiêu: Tìm bước đúng và an toàn nhất để làm dung lượng mới visible trong container mà không gián đoạn ứng dụng.

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

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

Đáp án đúng: Set the spec.resources.requests.storage value of the PVC object to match the size of the persistent disk. Apply the updated configuration by using kubectl.

Lý do 🛠️:

  • Đây là bước chính thức đầu tiên theo quy trình GCP/Kubernetes: Chỉnh sửa spec.resources.requests.storage của PVC (không phải PV) để khớp với kích thước PD mới (ví dụ: từ 10Gi tăng lên 20Gi).
  • Sau kubectl apply hoặc kubectl edit pvc <name>, Volume Expansion Controller sẽ tự động resize PV/PVC và file system (ext4/xfs) trong Pod mà không downtime (online expansion với CSI driver).
  • Khi Pod truy cập volume, dung lượng mới sẽ visible ngay. Nếu chưa, exec vào Pod chạy resize2fs /dev/... (nhưng không bắt buộc ở option này).
  • Kiến thức mới nhất (2026): PD CSI driver 1.14+ hỗ trợ fully online, không cần restart Pod.

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

  • ❌ [SAI] Set the spec.capacity.storage value of the PV object to match the size of the persistent disk. Apply the updated configuration by using kubectl.
    Giải thích: Không được chỉnh sửa thủ công spec.capacity.storage của PV vì đây là trường read-only do Kubernetes controller quản lý. Edit PV có thể gây lỗi validation hoặc inconsistent state. Quy trình yêu cầu update PVC trước, controller sẽ tự sync PV. (Không an toàn, vi phạm best practice Kubernetes).

  • ❌ [SAI] Recreate the application Pods by running the kubectl delete deployment DEPLOYMENT_NAME && kubectl apply deployment.yaml command, where the DEPLOYMENT_NAME parameter is the name of your deployment and deployment.yaml is its manifest file.
    Giải thích: Việc xóa và tạo lại deployment chỉ restart Pod (remount volume), nhưng không trigger volume expansion vì PVC vẫn giữ requests.storage cũ. Pod mới vẫn thấy dung lượng cũ. Gây downtime không cần thiết, không giải quyết gốc rễ.

  • ✅ [ĐÚNG] Set the spec.resources.requests.storage value of the PVC object to match the size of the persistent disk. Apply the updated configuration by using kubectl.
    Giải thích: Như phần trên, đây là bước chuẩn kích hoạt expansion. PVC requests tăng → controller resize PV/file system → Pod thấy dung lượng mới khi access/mount lại (online). Hiệu quả, zero-downtime.

  • ❌ [SAI] In the Pod, resize the disk partition to the maximum value by using the fdisk or parted utility.
    Giải thích: Nguy hiểm và không khuyến khích! fdisk/parted chỉnh partition table trực tiếp trong Pod, có thể corrupt data nếu Pod crash hoặc multi-writer. Kubernetes/GKE không hỗ trợ; phải dùng CSI driver + PVC update. Chỉ dùng resize2fs sau khi PVC resized, không phải partition. (Rủi ro cao, không theo docs).

Kết luận 🎯: Luôn ưu tiên update PVC trước khi can thiệp thủ công. Test bằng kubectl get pvc -o yaml và df -h trong Pod để verify!

Câu 280
You work for an ecommerce company. You are designing a new Orders API that will be exposed through Apigee. In your Apigee organization, you created two new environments named orders-test and orders-prod. You plan to use unique URLs named test.lnk-42.com/api/v1/orders and Ink-42.com/api/v1/orders for each environment. You need to ensure that each environment only uses the assigned URL. What should you do?
  1. A 1. Attach orders-test and orders-prod to the orders environment group.
    2. Add each hostname to the appropriate environment.
  2. B 1. Attach orders-test and orders-prod to the orders environment group.
    2. Add each hostname to the orders environment group.
  3. C 1. Attach orders-test to the test environment group, and attach orders-prod to the production environment group.
    2. Add each hostname to the appropriate environment.
  4. D 1. Attach orders-test to the test environment group, and attach orders-prod to the production environment group.
    2. Add each hostname to the appropriate environment group.
Xem giải thích

🧩 Giải thích nội dung câu hỏi

Câu hỏi xoay quanh việc thiết kế một Orders API cho công ty thương mại điện tử, được expose qua Apigee (nền tảng quản lý API của Google Cloud). Bạn đã tạo hai environments mới trong tổ chức Apigee: orders-test (môi trường test) và orders-prod (môi trường production). Mục tiêu là sử dụng URL unique cho từng môi trường:

  • test.lnk-42.com/api/v1/orders cho môi trường test.
  • lnk-42.com/api/v1/orders cho môi trường production.

Yêu cầu chính: Đảm bảo mỗi environment chỉ sử dụng đúng URL được gán, tránh xung đột hoặc chia sẻ hostname giữa các môi trường.

Trong Apigee (phiên bản mới nhất đến 2026), để đạt được điều này, bạn cần sử dụng Environment Groups (EGs) – một tính năng cho phép nhóm các environments và gán hostnames/virtual hosts trực tiếp vào EG, không phải vào environment riêng lẻ. Các environments phải được attach vào EG tương ứng, và API proxy sẽ được deploy vào environment, nhưng truy cập qua hostname của EG. Điều này đảm bảo isolation hoàn hảo giữa test và prod. 🛠️

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

Đáp án đúng là phương án cuối cùng (D):

  1. Attach orders-test to the test environment group, and attach orders-prod to the production environment group.
  2. Add each hostname to the appropriate environment group.

Lý do:

  • Bước 1 tạo hai EG riêng biệt (test EG cho orders-test và production EG cho orders-prod), đảm bảo isolation giữa môi trường test/prod.
  • Bước 2 gán hostname (test.lnk-42.com vào test EG, lnk-42.com vào production EG) – đúng theo cơ chế Apigee, nơi hostname chỉ attach vào EG, không phải environment trực tiếp.
  • Kết quả: Mỗi environment chỉ accessible qua hostname của EG riêng, tránh overlap. Đây là best practice theo docs Apigee mới nhất (2026). 📘

❌ Phân tích tất cả các phương án (đúng/sai)

Dưới đây là phân tích chi tiết từng lựa chọn. Tôi giữ nguyên văn bản gốc bằng tiếng Anh, chỉ giải thích bằng tiếng Việt với lý do đúng/sai rõ ràng:

  • Phương án A (SAI):

    1. Attach orders-test and orders-prod to the orders environment group.
    2. Add each hostname to the appropriate environment.

    Giải thích sai: Bước 1 attach cả hai environments vào cùng một EG (orders), dẫn đến chia sẻ hostname chung → không unique URL. Bước 2 sai cơ bản vì hostname không add trực tiếp vào environment, mà phải vào EG. ❌ Kết quả: Không isolation, vi phạm yêu cầu.

  • Phương án B (SAI):

    1. Attach orders-test and orders-prod to the orders environment group.
    2. Add each hostname to the orders environment group.

    Giải thích sai: Bước 1 vẫn attach cả hai env vào cùng EG → hostname của EG sẽ apply cho tất cả env trong nhóm, không tách biệt test/prod (ví dụ: cả hai có thể dùng cùng lnk-42.com). Bước 2 đúng về vị trí add hostname (vào EG), nhưng không giải quyết unique URL. ❌ Không đáp ứng "each environment only uses the assigned URL".

  • Phương án C (SAI):

    1. Attach orders-test to the test environment group, and attach orders-prod to the production environment group.
    2. Add each hostname to the appropriate environment.

    Giải thích sai: Bước 1 đúng (tạo EG riêng cho isolation). Nhưng bước 2 sai hoàn toàn vì Apigee không hỗ trợ add hostname trực tiếp vào environment – phải vào EG. Nếu thử, sẽ lỗi hoặc không hoạt động. ❌ Gần đúng nhưng fail ở bước quan trọng nhất.

  • Phương án D (ĐÚNG):

    1. Attach orders-test to the test environment group, and attach orders-prod to the production environment group.
    2. Add each hostname to the appropriate environment group.

    Giải thích đúng: Hoàn hảo! Bước 1 isolation env qua EG riêng. Bước 2 gán hostname chính xác vào EG tương ứng (test.lnk-42.com → test EG; lnk-42.com → production EG). API gọi qua EG hostname sẽ route đúng env. ✅ Best practice, scale tốt cho hybrid cloud.

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

Hy vọng phân tích này giúp bạn ôn thi hiệu quả! 🚀 Nếu cần ví dụ code deploy proxy, hỏi thêm nhé!