×
Community Blog Application Monitoring eBPF Edition: Non-intrusive Application Monitoring of the Golang Microservice

Application Monitoring eBPF Edition: Non-intrusive Application Monitoring of the Golang Microservice

This article introduces the importance of monitoring microservices in modern software architecture, and highlights the eBPF edition of application monitoring.

By Guqi

In modern software architecture, microservices have become a popular approach for building scalable and flexible applications. Each microservice is responsible for a specific function, working together to deliver a complete service. Due to the decentralized nature of microservice architecture, effective monitoring is crucial to ensuring high availability, reliability, and service quality. It supports the smooth operation of the entire system and enables continuous business growth..

With the popularization of Kubernetes and containerization technology, the Go language is not only applied to cloud-native basic components but also chosen by many emerging businesses as their preferred programming language in various business scenarios. Golang offers multiple RPC frameworks such as Gin, Kratos, and Kitex, and it continues to mature within the microservice ecosystem. According to the latest TIOBE index, Golang ranks in the top 10 programming languages. Therefore, application monitoring of Golang microservices becomes vital for businesses.

1

The eBPF edition of application monitoring enables non-intrusive observability for Golang microservices by utilizing eBPF technology. It allows capturing the call details of Golang microservices and facilitates non-intrusive CPU profiling and database call analysis for Golang applications.

For detailed product introduction, see Optimal Multi-language Application Monitoring: ARMS eBPF Edition

1. Introduction to eBPF

eBPF (extended Berkeley packet filter) is a powerful technology that allows developers to safely run pre-compiled programs on the Linux kernel without modifying the kernel source code or loading external modules. This unique capability makes eBPF an ideal choice for building modern, flexible, and efficient application monitoring tools.

2
Figure 1.1 How eBPF works

In terms of observability, the advantages of eBPF are prominent:

  • Real-time: eBPF can capture and analyze data in real time to provide developers with instant performance feedback.
  • Accuracy: eBPF can monitor specific points in the system by using fine-grained hook functions (hook points) to accurately collect required data.
  • Flexibility: developers can write custom eBPF programs to monitor specific events and adapt to various complex monitoring requirements.
  • Low overhead: the eBPF program runs directly in the kernel space. This avoids the frequent context switching between the user space and the kernel space in traditional monitoring tools.
  • Security: the eBPF program must pass strict kernel checks before it is executed, ensuring that system security is not compromised.

2. Application Monitoring of the Golang Microservice

To connect your Golang application to the application monitoring eBPF edition, see: https://www.alibabacloud.com/help/en/arms/application-monitoring-ebpf/getting-started/access-application-monitoring-ebpf-version

Connecting a Golang application using the Gin framework to the application monitoring eBPF edition involves adding the following configurations to the Deployment, as shown in the following figure

3

View application details after the application is connected:

4

Details of service interface call:

5

View details of the application call request, including the request body, header, and interface:

6
7

3. Continuous Profiling

Application monitoring eBPF edition introduces the capability of non-intrusive continuous application profiling. We use eBPF to obtain the call stack of the application program and implement the mapping of the corresponding stack ID to the method in the eBPF agent at the same time. We can view the CPU flame graph of the application and visually display the CPU-intensive points during the execution of the business application without any code modification. The flame graph of the HTTP service provided by the Go-Gin framework is shown as follows:

8

You can view the CPU percentage of processing HTTP requests:

9

If you add a function of printing data cyclically to the service:

func Print() {
  for {
    fmt.Println("This will print indefinitely every second.")
    time.Sleep(1 * time.Second) // Print data once per second
  }
}

You can find the corresponding Print function from the flame graph, which can quickly locate the CPU percentage in the Golang microservice:

10

4. Database Analysis

Database is the most widely used middleware product in business applications. Monitoring the calls of business applications to data can quickly find problems, such as slow SQL and the response time of calling databases. Application monitoring eBPF edition provides a call analysis page of databases, as follows:

11

View details of database calls, including the number of database calls, SQL statements (after aggregation), average duration, and number of slow calls (500 ms).

12

5. Network Monitoring

Data from network monitoring describes the number of received packets, the number of sent packets, TCP latency, TCP retransmission, and TCP drop of each instance corresponding to the application.

13

0 1 0
Share on

You may also like

Comments

Related Products