Author: CSDN cloud native

Recently, Alibaba Cloud aPaaS&Serverless front-end technical expert Yuan Kun shared the practice of Serverless in Alibaba Cloud function computing FC at the CSDN cloud native meetup Changsha station.

Internet Software Architecture Evolution

Let's briefly review the evolution of Internet software architecture.

Stand-alone deployment

In stand-alone deployment, all services and databases are deployed on one host.

 title=

The advantage of this architecture is that it is very simple to develop, deploy, and operate. The disadvantage is that once the traffic is too large or the machine fails, the entire system will be paralyzed, or even business data will be lost, resulting in huge business losses.

Cluster deployment

For the above-mentioned architectural problems, the common solution is to adopt the method of horizontal expansion for cluster deployment. Import traffic gateway routing of SLB for load balancing. Clustered deployment is essentially a monolithic architecture. Developers need to pay extra attention when developing projects. For example, to use cookies for authentication, sessions cannot be stored locally, and Redis needs to be introduced for separate storage. Clustered deployment can solve the problem of sudden traffic or machine failure through rapid horizontal expansion.

 title=

Microservice split

With the development of the business and the expansion of the team size, the tightly coupled approach of the monolithic architecture will bring more and more problems, and the flexibility and scalability of the architecture has become a major challenge that hinders the development of the business. The microservice architecture came into being.

 title=

Compared with the monolithic architecture, the microservice architecture is far more complex, and has also derived many new technologies, such as: API gateway, service registration, service discovery, and RPC communication.

Serverless Architecture

From a single architecture to a microservice architecture, from a single machine deployment to a clustered deployment, the Internet software architecture is becoming more and more complex, and the company needs to invest a lot of energy and cost to upgrade and maintain the underlying technology. The following figure shows the serverless architecture, which is different from the monolithic architecture by replacing the corresponding components with serverless cloud products.

 title=

The essence of technology evolution is to better serve the business. The traditional development method makes enterprises spend more energy on polishing the underlying technical details, while the serverless architecture allows developers to focus on business realization and create greater business value.

The advantages of a serverless architecture are obvious:

  • Don't focus on the underlying infrastructure, focus on business value creation
  • Automatic elasticity, calmly facing sudden traffic flow
  • Billing based on resource usage to avoid wasting idle resources

Discussion on Serverless Architecture

Let's first look at the execution process of FaaS. The blue part is manual management by users, only the code needs to be delivered, and other startup, operation, operation and maintenance are all carried out on the FaaS platform.

 title=

But this architecture creates some problems:

  • Fragmented code, unable to manage and deploy uniformly
  • The local environment and the online environment are inconsistent and cannot handle dependency compatibility issues
  • Difficulty in local debugging and online debugging
  • FaaS vendors have restrictions on code packages and cannot deploy large code packages
  • There is no uniform standard, leading to vendor lock-in issues

Serverless Devs

In response to the above problems, Serverless Devs can help developers better develop and manage serverless applications. It has the following characteristics:

  • No vendor lock-in, Serverless Devs helps developers deploy applications on various vendors
  • Open source and open, code logic without any black hole
  • The functions are pluggable, and Serverless Devs are provided in the form of components. Developers can quickly develop their own tool kits according to their needs.
  • Project full life cycle management capabilities, Serverless Devs is a tool for users to perform full life cycle management of project initialization, development, debugging, deployment, etc., simplifying serverless application development
If serverless architecture can help developers develop applications, then Serverles Devs is to help serverless developers develop better serverless applications!

Serverless Architecture in Practice

Serverless Devs official website practice

From the above introduction, it can be seen that Serverless Devs developer tools do not provide services. The implementation of services is provided by components, and the components themselves are scattered in different GitHub repositories.

The official website of Serverless Devs has the following demands:

  • Documents in GitHub sources under different repositories are brought together in one interface for display
  • Component developers focus on component documentation, and the documentation is automatically synchronized to the official website in real time
  • Once the components are changed, the official website can automatically deploy and build

The overall plan is as follows:

 title=

The developer updates the documentation on GitHub to trigger the Http Serverless function configured by the webhook hook. It should be noted here: due to the variable number of documents of the component and the unstable GitHub network, if all the work is processed in the Http function, it is very easy to cause a timeout, so put all the processing logic in the asynchronous call, and the execution is completed. Afterwards, the processed results are delivered to Dingding or mail and other channels.

Alibaba Cloud Function Compute Console Practice

The Alibaba Cloud Function Compute FC console is the first stop for users to use function computing products. The user experience of the console is very important. There are several problems with the architecture:

  • The back-end adopts a centralized deployment model, and the user's overseas access delay is very high
  • Users are required to manually build monitoring, logging, grayscale and other capabilities, resulting in high operation and maintenance costs
  • The research and development efficiency is low, the front and back ends need to coordinate and communicate during the development process, and the collaboration cost is high

The overall solution is as follows:

 title=

On the left is the general gateway of Alibaba Cloud, which is responsible for unified authentication and security logic, and extracts the BFF (Backend for Frontend) layer. The features of this part are as follows:

  • The overall BFF is deployed on Alibaba Cloud Function Compute FC, and developers do not need to manually operate and maintain
  • Front-end engineers are responsible for the BFF layer, and front-end engineers can better penetrate into the business and provide excellent user experience
  • Back-end engineers focus on the provision of underlying stability and atomic capabilities, and deliver them to BFF through SDK

 title=

The BFF implemented by serverless not only brings great flexibility to the business, but also has a qualitative change for the front-end engineer group: from the previous technical perspective to more focus on business value and user experience improvement.

CD build practices

The conventional self-built CD building cluster solution implements business logic orchestration through the Jenkins or Tekton framework, and uses K8s deployment at the resource level to achieve elastic scaling. If you need to implement a simple cloud-based CD solution, the above architecture is slightly more complicated.

The business scenarios of CI/CD have the following characteristics:

  • Triggered by events
  • Traffic cannot be predicted in advance
  • It needs to run in the background for a long time and is not sensitive to delay
  • Due to problems such as network delay, it is necessary to design a failure retry mechanism

These features are entirely tailored for Serverless. The implementation scheme also uses asynchronous functions, which lead all construction processes to asynchronous functions for processing. The entire orchestration logic is carried out through Serverless Devs, which perfectly realizes a stable CD construction cluster.

The underlying CD capability of the Alibaba Cloud Function Computing Application Center is based on the above principles, and you can experience it yourself.

 title=

async function

There are many scenarios in which asynchronous functions are used in practice. Here is a brief introduction to asynchronous functions.

 title=

In summary, asynchronous functions have four characteristics:

1. It can run for a long time, ranging from two hours to one day

2. Automatic termination can be set, time can be adjusted freely, and resources can be saved

3. The trigger result can be distributed to each event redemption center

4. There are three chances to automatically retry in case of failure


阿里云云原生
1k 声望302 粉丝