By Xiliu (Alibaba Cloud Function Compute Expert)
Speaking of the hottest technology currently, Serverless is an inevitable topic of discussion. As a new application architecture, Serverless allows us to get rid of the tedious maintenance of infrastructure. You only need to upload code packages or images to obtain a flexible, highly available, O&M-free, and low-cost service.
Serverless has many advantages but also has some pain points in the development process. The following troubles exist when using Serverless:
Industry research reports (Hacknoon Serverless Report) show that debugging is the biggest obstacle to Serverless landing.
The existing Serverless application debugging methods in the industry mainly perform debugging in the local simulation cloud execution environment, while applications running in the remote environment rely on logs. The real cloud environment cannot be simulated locally, so local debugging fails to solve the preceding problems. The industry's innovative end-cloud debugging function was launched for this reason.
The core idea of Serverless Devs end-cloud debugging is to enable the local development environment to break through network restrictions and integrate with the cloud environment. Developers can launch instances locally and connect to the cloud environment seamlessly through end-cloud debugging to perform testing and problem debugging. End-cloud debugging can help developers:
As shown in the following figure, end-cloud debugging establishes a secure tunnel connection between the local development machine and the VPC environment of the cloud application.
The traffic that accesses the cloud application is forwarded to the local development machine. At the same time, the network traffic accessed by the local instance is also forwarded to the VPC environment of the cloud application.
For example, if you use a local instance to access an ApsaraDB for RDS instance on the cloud, you can only access the ApsaraDB for RDS instance from the Internet or purchase a VPN service to access an online VPC. You can access the RDS instance in the intranet by end-cloud debugging without any configuration changes.
The user executes the
s proxied setup in the s.yaml directory, and this command does the following:
There will be a secondary function to reserve 1 instance. After debugging, you can manually clean up the resources to avoid unnecessary costs.
CTRL + Cthe interruption in the terminal that opens end-cloud debugging
s proxied cleanupin the same directory
You can use one of the preceding methods (1 or 2). You can also execute the
s proxied cleanup multiple times.
Even if you forget to clean up and the local development authority or network is disconnected, the channel session will be closed, and the reserved resources will be cleaned up.
Let's use Alibaba Cloud Function Compute (FC) and a real enterprise customer as an example. Mr. Wang is a developer of a business-driven company. The company's technical architecture has evolved to full cloud-native and reduced infrastructure management and O&M to improve business iteration efficiency. The following is the architecture:
Mr. Wang migrated the most frequently iterated projects that separated the front and backend to the Function Compute Custom Runtime with one click. Spring Boot projects need to be able to access downstream services (such as registration centers or other microservice interfaces) by using various VPC intranet addresses.
At this time, the end-cloud debugging provided by Serverless Devs can be used. You only need to execute it in the directory where s.yaml (the VPC configuration with functions defined in s.yaml) is located.
$ s proxied setup
The command establishes a secure network channel with the cloud VPC environment and starts the application instance locally. As such, the on-premises instance can seamlessly access resources in the cloud VPC environment, such as using the internal endpoint to access the registry, RDS, and Kafka. This means your application configuration does not need any changes to interact with resources within local and cloud environments.
At the same time, directly use the custom domain name corresponding to the Spring Boot backend project on the Function Compute FC, and traffic will be routed to the local application instance.
For example, the function name of your frontend project deployed to FC is a frontend, and its corresponding custom domain name is
frontend.abc.com. The function name of the backend service that the frontend depends on and is deployed on FC is the backend, and the corresponding custom domain name is
At this time, you can open
fronted.abc.com in the browser and perform operations with backend requests. Traffic is routed from online to the local Spring Boot instance. At the same time, Spring Boot logs are displayed in real-time on the terminal. You can use breakpoints to debug traffic online.
Let's assume the instance of the Spring Boot backend project fails to start locally. Possible causes include incorrect VPC configurations of the Function Compute and whitelist limits for the corresponding downstream services. At this point, you can reproduce the same startup process as the cloud environment instance locally, which is helpful in troubleshooting problems with instance startup. As shown in the following figure:
With the information from the startup process of the local instance, the cause of Nacos access failure can be identified. We need to check whether the function has correctly configured the VPC where Nacos is located or whether Nacos has whitelist restrictions.
Finally, we use a table to summarize the differences between local debugging and end-cloud debugging.
Serverless is the default computing paradigm for cloud computing for the next ten years. Currently, debugging is one of the biggest challenges in Serverless. Compared with other businesses that only provide local debugging capabilities, Alibaba Cloud Function Compute (FC) proposed end-cloud debugging and achieved a good developer experience through tools, improving the development efficiency and happiness of developers of Serverless applications.
1688's Serverless Efficiency Improvement Practices in Complex Business Scenarios
Useful Debugging Practices: How to Realize Serverless Breakpoint Debugging
77 posts | 6 followersFollow
Alibaba Cloud Serverless - June 13, 2022
Alibaba Cloud Community - November 25, 2021
Alibaba Cloud Community - December 21, 2021
Alibaba Clouder - May 27, 2019
Alibaba Cloud Serverless - August 21, 2019
Alibaba Cloud Serverless - February 28, 2023
77 posts | 6 followersFollow
Alibaba Cloud Function Compute is a fully-managed event-driven compute service. It allows you to focus on writing and uploading code without the need to manage infrastructure such as servers.Learn More
Visualization, O&M-free orchestration, and Coordination of Stateful Application ScenariosLearn More
Serverless Application Engine (SAE) is the world's first application-oriented serverless PaaS, providing a cost-effective and highly efficient one-stop application hosting solution.Learn More
Resource management and task scheduling for large-scale batch processingLearn More
More Posts by Alibaba Cloud Serverless