Start from scratch Serverless | SAE's remote debugging and cloud joint debugging

Head picture.jpg

Source | Serverless Official Account

Author | Yichuan Alibaba Cloud Native Team

Introduction: This section of the course contains three parts. The first two parts briefly introduce the principles of remote debugging and device-cloud joint debugging. Finally, a practical demonstration is carried out in the Serverless application engine.

After studying the previous courses, I believe that everyone has a certain understanding of Serverless Application Engine (SAE). SAE is an application PaaS platform based on containers and kuberneters. In the Serverless scenario provided by SAE, we no longer need to pay attention to underlying resources For operation and maintenance, you only need to focus on the business logic of the application itself. However, we usually need to use the debugging function in the development and testing phase. Therefore, in order to facilitate user debugging, we provide the remote debugging function. Currently, only the remote debugging of Java programs is supported.

Remote debugging

Principles of Java remote debugging

1.png

As we all know, our Java programs run on the Java Virtual Machine (JVM). JVM not only provides cross-platform capabilities for our Java programs, but also provides corresponding interfaces and protocols to facilitate remote debugging. There is a system called JPDA in the JDK to standardize and support the debugging of Java programs. In this system, the JVM bottom layer of the debugger and the debugged program are supported by the JDI and JVMTI modules respectively, and there is a difference between the two interfaces. JDWP is responsible for the communication between each other.

It can be seen that the essence of remote debugging is that two JVMs maintain communication through a connection. The program being debugged acts as a server and listens to debugging instructions on a specified port. The debug initiator acts as a client to connect to the target port and send Various debugging commands and receiving debugging status.

We have now understood the principle of remote debugging of Java programs, so how do you implement remote debugging for Java applications deployed in SAE?

Java remote debugging in SAE

2.png

First, the Java application deployed in SAE needs to turn on the debugging mode first, so you need to add related startup commands when deploying the application. In addition, because SAE applications cannot provide public network access by default, an SLB is required to provide public network access capabilities. After the above two are set up, you can finally get an IP and port for the debugging program. Set this IP+port to the IDE to start remote debugging.

Note: For the above operations, see the article [Practical Demonstration].

End-cloud joint debugging

In addition to remote debugging, device-cloud joint debugging is also a very important function for microservice applications.

In our development and testing process under the microservice architecture, we often encounter situations where we need to launch a new service or update the version of an old service. If there is no end-cloud joint debugging, we can only go to the production environment after testing in the test environment. Usually, the test environment and the production environment are different in one way or another, resulting in some hidden problems that cannot be discovered in time.

With the end-cloud joint debugging function, we can directly implement mutual calls between local services and services deployed in the cloud before it is officially launched, so that we can be closer to the actual production environment for debugging.

3.png

First, the services deployed on SAE are isolated from the local network, so you need to purchase an ECS under the same VPC to act as a springboard. With this springboard, we can complete the registration and service discovery of local services in the cloud registry through IDEA's plug-ins. Finally, end-cloud interconnection can be completed, and end-cloud joint debugging can be carried out.

Practical demonstration

Finally, a practical demonstration of the remote debugging and terminal cloud joint debugging functions provided by SAE, please click the link for the demonstration process:https://developer.aliyun.com/lesson_2026_23271#_23271 to watch.

Guess you like

Origin blog.51cto.com/14902238/2561365