Introduction: From monolithic architecture to microservice architecture, from stand-alone deployment to 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. However, the serverless architecture allows developers to focus on business implementation to create greater business value.
Author | Organized by Yuan Kun | Produced by Xu Shiyao | CSDN Cloud Native
Internet Software Architecture Evolution
Let's briefly review the evolution of Internet software architecture. Single-machine deployment In a single-machine deployment, all services and databases are deployed on one host.
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.
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.
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 companies need 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.
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:
●Do not focus on the underlying infrastructure, focus on business value creation
●Automatic elasticity, calmly facing sudden traffic flow
●According to resource usage to avoid waste of idle resources Serverless architecture discussion Let's first look at the implementation 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.
But this architecture creates some problems:
●The code is fragmented and cannot be managed and deployed uniformly
●The local environment and the online environment are inconsistent and cannot handle dependency compatibility issues
●It is difficult to perform local debugging and online debugging
FaaS vendors have restrictions on code packages and cannot deploy large code packages
●There is no unified standard, which leads to the problem of vendor lock-in
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 source, no black holes in the code logic
Functions can be pluggable, 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 capability. 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 the Serverless Devs developer tools do not provide services, and 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 solution as follows:
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, and the user experience of the console is very important.
There are several problems with the architecture:
●The back-end adopts a centralized deployment mode, and the user's overseas access delay is very high
●Require users to manually build monitoring, logging, grayscale and other capabilities, resulting in high operation and maintenance costs
●The efficiency of research and development is low, the front and back ends need to coordinate and communicate during the development process, and the cost of collaboration is high. The overall solution is as follows:
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 operate and maintain it manually ●The front-end engineer is responsible for the BFF layer, and the front-end engineer can better penetrate into the business and provide an excellent user experience ●The back-end engineer focuses on the underlying stability and atomicity The provision of capabilities is delivered to the BFF through the SDK
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 features: ● Execution is 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 by 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.
async function
There are many scenarios in which asynchronous functions are used in practice. Here is a brief introduction to asynchronous functions.
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
1 minute Serverless to build a real website
Alibaba Cloud cloud native application platform and Yunqi Lab have launched a scenario experience. After completing the following experience from 2022.6.20 to 2022.7.1 (during working days), you will have the opportunity to receive a 10 yuan voucher from Tmall Supermarket.
- Quickly build Zblog blog system
Experience address:
https://developer.aliyun.com/adc/series/activity/serverless2022
Copyright statement: The content of this article is contributed by Alibaba Cloud's real-name registered users. The copyright belongs to the original author. The Alibaba Cloud developer community does not own the copyright and does not assume the corresponding legal responsibility. For specific rules, please refer to the "Alibaba Cloud Developer Community User Service Agreement" and "Alibaba Cloud Developer Community Intellectual Property Protection Guidelines". If you find any content suspected of plagiarism in this community, fill out the infringement complaint form to report it. Once verified, this community will delete the allegedly infringing content immediately.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。