A ride-hailing company publishes trip events to a Pub/Sub topic consumed by a pool of workers. Operators want a Cloud Monitoring signal showing how many messages are still waiting to be acknowledged on the subscription, so they can detect consumers falling behind. Which metric is appropriate?
Show answer and explanation
Answer: D
The num_undelivered_messages metric on a Pub/Sub subscription counts messages that have been published but not yet acknowledged by the subscriber. A rising value means consumers are not keeping up, which makes it a direct backlog and lag indicator. Publisher CPU, egress, and disk IOPS describe infrastructure load and do not reveal whether subscribers are falling behind.
Why the other options are wrong
- A. Publisher CPU reflects how hard the ingestion machine works. It says nothing about whether subscribers have acknowledged what was published, so it cannot reveal consumer lag.
- B. Network egress measures bytes leaving the project. Trip events may keep arriving at the same rate while workers fall behind, so egress does not indicate backlog.
- C. Disk IOPS on worker instances describes local storage activity. Pub/Sub stores messages in the service rather than on those disks, so this metric cannot show subscription backlog.