ALERT: Due to maintenance activity, you might not see any screenshots. Your patience is highly appreciated. Thanks!!
This lab walks you through Using Google Cloud Profiler.
Duration: 60 minutes
You can think of Cloud Profiler as an agent added to your code that gathers CPU usage and memory-allocation information from your production applications and send it to Monitoring Graphs in Google Cloud. As most the applications are not Monolithic today, you can add the agent to different microservices and it will help you identify the parts of the application consuming the number of resources and other performance characteristics of the code. Cloud Profiler creates a single profile by collecting profiling data, usually for 10 seconds, every 1 minute for a single instance of the configured service in a single Compute Engine zone.
For every running production application, Cloud Profiler creates a separate profile. It collects Google Cloud Project, Application Name, Application Version, and Application Zone. When an agent is ready to capture a profile, it issues a Profiler API command to the Profiler backend. The backend receives this request and, immediately replies to the agent. The reply specifies the type of profile to capture. In response, the agent captures the profile and transmits it to the backend. Lastly, the Profiler backend associates the profile with your Google Cloud project.
The profile data is retained for a period of 30 days.
Cloud Profiler is very Light-Weight and thus has near about no effect on the production application.
Gathering Performace characteristics such as Memory-allocation, and CPU Cycles is a very difficult task in the Production environment as compared to the test environment, which the Cloud profiler performs very efficiently.
You dynamically analyze your code and can make it efficient and faster in the Production environment.
Profiling agent: You install this agent on the virtual machines or where your application runs. The agent typically comes as a library that you attach to your application when you run it.
Profiler interface: After the agent has collected some profiling data, it displays all the data collected by it in a Frame Interface.
CPU Time: It is the time for which the CPU was used for executing the code.
Heap: The amount of memory allocated in the heap at the instant profile was created.
Allocated Heap: The total amount of heap-allocated.
Contention: In a multi-threaded program, the time spent waiting to serialize access to a shared resource can be significant.
Threads: A thread is a single flow of tasks.
Wall Time: It describes the total time used by code from entering to exiting. While executing a code there are various processes at the backend such as wait time(the process is in the queue) by the CPU.
Creating a VM Instance.
SSHing into the VM and running the Node.js Application.
Exploring Cloud Profiler.