Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to analyze the one-stop Serverless development solution of IMWEB front-end team

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article shows you how to analyze the IMWEB front-end team one-stop Serverless development solution, the content is concise and easy to understand, can definitely make your eyes bright, through the detailed introduction of this article, I hope you can get something.

Today's Serverless can be said to be a potential new technology direction, especially in the current upsurge of cloud, because of its advantages such as free operation and maintenance, automatic expansion and support for multiple programming languages, Serverless is not only a sharp tool to improve the efficiency of service development and maintenance, but also a way to try the direction of full stack development, but also because of its newness, it also meets some challenges for landing into team development and combining team development flow. The following will share the practice of the IMWEB team on Serverless

First, the evolution and thinking of Serverless research and development mode of IMWEB team.

In the past year or two, our team has tried to use serverless in a number of service projects. Tencent Cloud Serverless provides an one-stop service. By using this service, the front end can independently complete the development of interface services, and for front-end individuals, it can develop to a full stack, thus alleviating the shortage of manpower in the background of the team.

In the process of developing Serverless cloud functions, we have also encountered some challenges compared with traditional services.

(1) characteristics of cloud function development

The development flow mode of the front-end traditional project is relatively mature. Through git to manage the code together, and then through CI to standardize the project deployment process, the whole workflow can view and roll back the code, and the deployment is automated.

Let's take a look at the development features of cloud functions:

Independent account and permission management of cloud function

Create, update, and deploy functions as units

Create a gateway API to associate with a function, so that the cloud function can be accessed through the gateway API

The above are the three basics of developing cloud functions

There are two ways to create and update cloud functions:

Tencent Cloud official website Cloud function console, visual operation interface. Click the button to create and update.

Created through CLI, SERVERLESS provides SDK, and calls SDK to complete custom creation and update operations. It has the advantages of flexible writing and easy engineering.

Considering team collaboration, the second way is to call SDK because it is more flexible and more suitable to be customized to the team specification.

To sum up, you can see three features of cloud function development:

Because it has a cloud function account independent of the git account, the code of the cloud function is lacking, like GIT, you can view the historical code version, code modification record and so on.

Because it has multiple ways to create and update functions, there is a risk of overriding cloud functions when multiple people cooperate.

The provided cloud function gateway can help quickly configure and access cloud functions without the help of operation and maintenance students to do domain name pointing, machine application and so on.

(2) the problem of cloud function development in teamwork

In the initial stage, when the team explored and tried the development of cloud function, compared with the development flow of traditional projects, there were more development steps and some shortcomings were exposed:

1) the cost of operation is high

First of all, there are considerable learning costs, such as cloud function configuration files, cloud function official website interface operation and learning costs. In actual use, because the cloud function gateway API link is too long and the domain name is limited, it is necessary to configure nginx and use a specific domain name to access the cloud function gateway API. Because most front ends are deployed to nginx, there is a nginx learning cost.

2) the efficiency of debugging cloud function is low

Because cloud functions are deployed on the cloud, Serverless has its own unique environment, context, event, etc., which is different from the request body of NODE service. It is difficult to simulate serverless requests locally, so when developers want to debug positioning problems, they can only deploy the code on serverless first. Here, you need to wait for deployment. Because serverless is extranet, the deployment time is even longer.

3) Development flow confusion

Since cloud functions are directly deployed on the cloud, there is no traditional machine for environment differentiation, which is not friendly to teamwork to ensure the quality of deployment.

As mentioned above, it is often because you want your own business domain name to access the service interface, and the cloud function gateway API is a long link that lacks semantics. When you use it, you usually want to configure nginx to access cloud functions through a custom domain name, not only because of the cost, but also because of the risk of misconfiguration.

4) difficulties in management and quality problems

Due to the independent account management of cloud function, there is no git to manage, so code records cannot be tracked. Even anyone with permission to create a function with the same name for deployment will cause the function to be overwritten inexplicably. The same cloud function gateway API can also be changed to point to other cloud functions at will.

To sum up, the challenges encountered in teamwork SCF development are as follows:

Second, the breaking and landing of IMFLOW one-stop Serverless development solution.

Summarize some of the problems encountered in team collaboration with the above cloud function, and propose solutions accordingly:

Formulate norms to ensure unified collaboration, unified norms to ensure a unified workflow, improve development efficiency and then ensure quality

Optimize the experience of cloud function development, automate repetitive and redundant operations through tools, and filter out some development and learning costs through encapsulation

Make CI and CD according to the characteristics of SCF to ensure the unity of process and improve the deployment efficiency; unify gateway rules and reduce the learning and operation of SCF gateway API

(1) formulate norms to improve collaboration efficiency. 1) unify cloud account management.

For independent cloud function accounts, each developer needs to apply separately before starting the development, and at the same time, open all kinds of permissions, hurry up for half a day and slow down for a day or two. To solve this problem, consider using team public accounts for unified cloud function management. Tools use public accounts to deploy and update cloud functions, eliminating the learning cost of development and the cost of getting started with accounts.

2) manage cloud functions based on GIT

For the independent management of cloud function, in order to track the cloud function uniquely, the original git management project code is retained, and a series of specifications are formulated to uniquely associate the git project with the cloud function to ensure that the cloud function is unique and uncovered.

3) Namespace isolates the function environment

In order to provide the development flow of cloud functions, according to the characteristics of cloud functions, the concept of cloud function namespace is used to isolate cloud functions, and the gateway service in the test environment is limited to private network access to ensure business security.

4) configuration of unified cloud function rules

Formulate naming conventions for cloud function names, corresponding gateway service API names and environment namespaces to achieve one-to-one correspondence among namespaces, function names and gateway service API. The second can be deduced from one of them. If you know the function name, you can know what the access API is and what the corresponding environment namespace is.

(2) self-developed CLI tools, IMFLOW to improve the efficiency of SCF research and development

After the first specification is established, tools are needed to make the specification fall into place. The IMWEB team developed the CLI tool-IMFLOW, which provides a practical solution for the development flow of the SCF team to improve the efficiency of SCF R & D by means of tools, such as creating accounts, applying permissions, creating cloud functions, developing cloud functions debugging, cloud function gateway API association, function isolation, and so on. Enter commands through the CLI tool.

1) getting started is faster.

After using the CLI tool to assist, compared with the team's past development mode, you can get started in 2 minutes through CLI.

2) the debugging experience is consistent with the traditional service development.

Through the way of isomorphism + construction, the traditional service development experience is retained, and the cloud function files are encapsulated and shielded by the tool, so that developers can develop as before.

3) one-click positioning and debugging cloud function

The real running environment of the cloud function is relatively complex. If you encounter problems related to debugging the cloud function environment, you need to debug the cloud function. At this time, the debugging can be completed locally. The tool encapsulates a series of operations, such as real-time debugging, monitoring file changes, and so on. Real-time deployment to achieve one-click positioning debugging cloud function

4) optimize the deployment time of cloud function

The deployment of the cloud function is based on the public network, and the deployment time of the cloud function affects the release time of the cloud function, and even affects the debugging efficiency of the cloud function when doing local real-time debugging of the cloud function. In order to optimize the deployment time of the cloud function, it makes use of the layer feature of the cloud function, the small probability of node_module change of the project, and the deployment time affected by the size of the contemporary code package. Split the deployment of the cloud function project, and there is no need to deploy node_modules when there is no change in node_modules, thus reducing the deployment time

After the deployment optimization is done, check the deployment time of the project. Most of the time can be 35 seconds to complete the function deployment.

(3) quality assurance

In terms of quality assurance, it is mainly through the deployment process of CI | CD specification and the development of gateway service specifications to isolate cloud functions and reduce gateway configuration costs.

Restrict the test environment gateway service to be accessible through the private network.

In addition, in order to ensure the stable operation of the cloud function and avoid the failure of access to the cloud function due to the cold start of the cloud function, that is, the disaster recovery of the cloud function, we have done a layer of STKE disaster recovery, through the way of isomorphism of code, using tools to build and package, to complete a set of code implementation that can deploy both serverless and STKE, and cooperate with the processing of the gateway to complete the degradation and disaster recovery of the cloud function.

3. IMFLOW uses imflow built-in commands

The above is how to analyze the one-stop Serverless development solution of the IMWEB front-end team. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report