
Answer-first summary for fast verification
Answer: 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.
To identify which source code is consuming the most CPU and memory resources, Cloud Profiler (Option B) is the correct choice. Cloud Profiler is specifically designed for continuous profiling of applications, collecting detailed data on CPU and memory usage. By importing the Profiler package and initializing the agent, the tool generates flame graphs in the Google Cloud console, which visually highlight time-intensive and resource-heavy functions. This directly addresses the need to pinpoint resource consumption at the code level. Other options are less suitable: Snapshot Debugger (A) focuses on debugging specific breakpoints, not continuous profiling. OpenTelemetry and Trace (C) target latency analysis in distributed tracing, not resource utilization. Logging-based analysis (D) relies on manual log parsing and lacks the granularity of a dedicated profiler.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
To identify the source code consuming the most CPU and memory resources in a Go web application deployed on Google Kubernetes Engine, what steps should you take?
(Optional code block if applicable, corrected for syntax/typos):
// Example placeholder for potential code analysis
func resourceIntensiveFunction() {
// Logic causing high CPU/memory usage
}
// Example placeholder for potential code analysis
func resourceIntensiveFunction() {
// Logic causing high CPU/memory usage
}
A
Download, install, and start the Snapshot Debugger agent in your VM. Take debug snapshots of the functions that take the longest time. Review the call stack frame, and identify the local variables at that level in the stack.
B
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.
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 where bottlenecks are occurring.
D
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 identity time-intensive functions.