To remotely diagnose applications deployed on Serverless App Engine (SAE), you can use the SAE remote debugging feature. This topic describes how to remotely debug using a jump server and OpenSSH.
Prerequisites
Background information
A jump server is a server used to access other machines. For SAE, a jump server's core function is to establish a network connection between your local environment and remote SAE application instances for remote management over the SSH protocol. SAE provides namespace-level jump servers. After you associate a jump server with the same VPC as your namespace, you can log on to all application instances in that namespace with a single click. This enables network access and remote debugging between your local machine and SAE application instances.
Remote debugging is intended for temporary use only. Leaving remote debugging enabled for long periods can create security risks, such as data leaks. After you finish remote diagnostics, immediately delete the jump server to disable the remote debugging feature.
Step 1: Configure a jump server
-
Log on to the SAE console.
-
In the left-side navigation pane, click Namespaces. In the top navigation bar, select a region. Then, click the name of a namespace.
-
On the Basic Information tab, in the Jump Server Information section, click Associate Jump Server.
-
In the Add Jump Server panel, configure the parameters.
-
On the Configure Jump Server Creation Information tab, configure the parameters and click Next.
Parameter
Description
VPC
The VPC is the same as the one associated with the target SAE application. This parameter is automatically populated.
vSwitch
You must specify at least one vSwitch, with a recommended maximum of three. You can click Change to view and select a vSwitch in a recommended zone in the Select vSwitch dialog box.
security group
Ensure the selected security group has an inbound rule that allows access on TCP port 22.
SSH certificate
Enter the SSH certificate in the code editor or click Select File to upload it.
You can run the
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"command to generate an SSH certificate. For more information on obtaining an SSH certificate, see Generating a new SSH key and adding it to the ssh-agent. -
On the Create Jump Server Resource tab, confirm the configuration information and click OK.
The system automatically creates a 0.5 vCPU/1 GiB jump server instance and an Elastic IP Address (EIP) in the specified VPC and vSwitch for the current namespace. You are charged for the resources on a pay-as-you-go basis. For more information, see SAE pay-as-you-go billing and Pay-as-you-go EIPs.
After the jump server is created, you can view its network configuration, including the EIP, VPC, vSwitch, and security group, on the Basic Information tab.
-
Step 2: Install OpenSSH
You can install OpenSSH to enable remote logon over SSH and file transfers over SFTP or SCP. This allows you to temporarily debug a specific SAE application instance. For more information, see Copy Installation Command.
-
Log on to the SAE console.
-
In the left-side navigation pane, click Applications. In the top navigation bar, select a region. Then, click the name of an application.
-
On the Basic Information page, click the Instance Deployment Information tab. In the Default Group section, find the target instance and click Webshell in the Actions column.
Click the
icon in the upper right corner of the webshell window. -
In the Copy Command dialog box, select the Install openssh checkbox, preview the command, and then click Copy.
-
Run the following commands in the Webshell window to configure OpenSSH.
-
Run the copied OpenSSH installation command.
-
Run the passwd command to set the instance password for login.
-
Step 3: Perform remote debugging
After you enable remote debugging, you can use the IP address and port from the jump server to debug the instance from any host with an SSH client and internet access. The following scenarios show how to verify your setup.
Scenario 1: Access an SAE instance from a local machine
Run the following command:
ssh root@{SAE application instance IP} -J root@{jump server IP}
Scenario 2: Map an instance port to a local port
Run the following command:
ssh -L {local_debugging_port}:{SAE_application_instance_IP}:{SAE_application_instance_port} root@{jump_server_IP} -N
Scenario 3: Remotely debug a Java application
-
Log on to the SAE console.
-
In the left-side navigation pane, click Applications. In the top navigation bar, select a region. Then, click the name of an application.
-
In the upper-right corner of the Basic Information page, click Deploy Application.
-
On the Deploy Application page, expand the Startup Command Settings section and set the startup command. After you complete the settings, click Confirm.
The required startup command parameters depend on the Application Deployment Method that you selected when creating the application.
ImportantThe application restarts after you click Confirm. To prevent unexpected errors, we recommend that you deploy applications during off-peak hours.
-
Image
In this example, the
ENTRYPOINT: [nginx, '-g', 'daemon off;']command is configured. The following table describe the parameters in the command.Parameter
Description
Startup Command
Enter a startup command. Example:
nginx.Startup Parameter
Enter a startup parameter. Example:
-g.Click + Add to add a parameter in a new line. Example:
daemon off. -
JAR package
Parameter
Description
Default Startup Command
The default startup command that is provided by SAE.
options Settings
The JVM parameters. For more information, see JVM options, Tuning Java Virtual Machines, and JVM Tuning: How to Prepare Your Environment for Performance Tuning.
If you want to use the remote debugging feature of the application, configure the following command according to the JDK version:
JDK 11 and JDK 17
-agentlib:jdwp=transport=dt_socket,address=*:9000,server=y,suspend=nOther JDK versions
-agentlib:jdwp=transport=dt_socket,address=9000,server=y,suspend=n
where:
transport: the method that is used to transmit data during remote debugging.
address: the IP address of the client from which the O&M engineer performs remote debugging. Use the port that you specified when you enabled remote debugging. For more information, see Perform remote debugging.
ImportantThe startup command that is used when you deploy an application by using a WAR package is different from the startup command that is used when you deploy an application by using a JAR package. We recommend that you do not use the same startup command when you deploy applications by using different methods. You can use the preceding remote debugging command to debug an application regardless of whether you use a WAR package or a JAR package to deploy the application.
args Settings
The redirection parameter for standard output (stdout) and standard errors (stderr). Example:
1>>/tmp/std.log>&1.options Shortcut Settings
This parameter is available only if you set the Java Environment parameter to Dragonwell.
Enable Performance Improvement for Microservices (Wisp2 Coroutine): By default, this feature is enabled. This feature improves the performance of multiple threads at runtime.
Enable Application Memory Optimization (G1): By default, this feature is enabled. This feature reduces the GC time in scenarios in which multiple CPUs and large-capacity memory are required. This feature is also suitable for GC optimization and big data scenarios.
Enable Application Startup Acceleration (Quickstart): This parameter is available only if you set the Java Environment parameter to Dragonwell 11. You can select Enable Application Startup Acceleration (Quickstart) and configure the Persistent Storage Directory parameter to improve the application startup efficiency.
ImportantBefore you select Enable Application Startup Acceleration (Quickstart), you must configure a File Storage NAS file system. For more information, see Configure NAS storage.
Persistent Storage Directory: This parameter is required if you select Enable Application Startup Acceleration (Quickstart). To accelerate application startup across instances, we recommend that you set the Persistent Storage Directory parameter to the directory or subdirectory of the NAS file system. For information about how to configure a NAS file system, see Configure NAS storage.
-
WAR package
Parameter
Description
Default Startup Command
The default startup command that is provided by SAE.
options Settings
The JVM parameters. For more information, see JVM options, Tuning Java Virtual Machines, and JVM Tuning: How to Prepare Your Environment for Performance Tuning.
If you want to use the remote debugging feature of the application, configure the following command according to the JDK version:
JDK 11 and JDK 17
-agentlib:jdwp=transport=dt_socket,address=*:9000,server=y,suspend=nOther JDK versions
-agentlib:jdwp=transport=dt_socket,address=9000,server=y,suspend=n
where:
transport: the method that is used to transmit data during remote debugging.
address: the IP address of the client from which the O&M engineer performs remote debugging. Use the port that you specified when you enabled remote debugging. For more information, see Perform remote debugging.
ImportantThe startup command that is used when you deploy an application by using a WAR package is different from the startup command that is used when you deploy an application by using a JAR package. We recommend that you do not use the same startup command when you deploy applications by using different methods. You can use the preceding remote debugging command to debug an application regardless of whether you use a WAR package or a JAR package to deploy the application.
options Shortcut Settings
This parameter is available only if you set the Java Environment parameter to Dragonwell.
Enable Performance Improvement for Microservices (Wisp2 Coroutine): By default, this feature is enabled. This feature improves the performance of multiple threads at runtime.
Enable Application Memory Optimization (G1): By default, this feature is enabled. This feature reduces the GC time in scenarios in which multiple CPUs and large-capacity memory are required. This feature is also suitable for GC optimization and big data scenarios.
Enable Application Startup Acceleration (Quickstart): This parameter is available only if you set the Java Environment parameter to Dragonwell 11. You can select Enable Application Startup Acceleration (Quickstart)and configure the Persistent Storage Directory parameter to improve the application startup efficiency.
Important
Before you select Enable Application Startup Acceleration (Quickstart), you must configure a File Storage NAS file system. For more information, see Configure NAS storage.
Persistent Storage Directory: This parameter is required if you select Enable Application Startup Acceleration (Quickstart). To accelerate application startup across instances, we recommend that you set the Persistent Storage Directory parameter to the directory or subdirectory of the NAS file system. For information about how to configure a NAS file system, see Configure NAS storage.
-
-
Enable debugging for the target SAE application instance by following the instructions in Step 1: Configure a jump server and Step 2: Install OpenSSH.
-
Run the following command to map a port from the SAE application instance to a local port.
ssh -L {local_debugging_port}:{SAE_application_instance_IP}:{SAE_application_instance_port} root@{jump_server_IP} -N -
Connect to
127.0.0.1:{local_debugging_port}from your local machine to begin debugging.
Delete a jump server
-
Go to the SAE namespace page. In the top navigation bar, select the target region. Find the target namespace and click Delete Jump Server in the Jump Server Information column.
-
Follow the on-screen instructions.
More information
If you configure a health check for the Java remote debugging port, you must set the breakpoint suspend policy in IntelliJ IDEA to Thread during debugging. Otherwise, the health check will fail. For more information, see Configure health checks. In the breakpoint settings, ensure the Enabled and Suspend checkboxes are selected, set the suspend policy to Thread (not All), and click Done.