Profiling Go services
In this section, we are going to review a technique called profiling, which involves collecting real-time performance data of a running process, such as a Go service. Profiling is a powerful technique that can help you analyze various types of service performance data:
- CPU usage: Which operations used the most CPU power and what was the distribution of CPU usage among them?
- Heap allocation: Which operations used heap (dynamic memory allocated in Go applications) and what amount of memory was used?
- Call graph: In which order were service functions executed?
Profiling may help you in different situations:
- Identifying CPU-intensive logic: At some point, you may notice that your service is consuming most of your CPU power. To understand this problem, you can collect the CPU profile – a graph showing the CPU usage of various service components, such as individual functions. Components that consume too much CPU power may indicate...