Introduction to above that the development of cloud computing over the past ten years has brought earth-shaking changes to the entire Internet industry. Serverless, as a product of cloud computing, or the performance of cloud computing in a certain era, is considered by many people to be true In the sense of cloud computing, the question of "what is serverless" can actually be analyzed from different perspectives.
Author | Liu Yu
Preface
As mentioned above, the development of cloud computing for more than ten years has brought earth-shaking changes to the entire Internet industry. Serverless, as a product of cloud computing, or the performance of cloud computing in a certain era, is considered by many people to be the true cloud. In computing, the question of "what is serverless" can actually be analyzed from different angles.
Martin Fowler gave the definition of Serverless from the perspective of the composition of Serverless in the article "Serverless Architectures". He believed that Serverless was actually a combination of BaaS and FaaS, and gave a detailed description of BaaS and FaaS.
Serverless was originally used to describe applications that mostly or completely rely on third-party (cloud) applications or services to manage server-side logic and state. These applications are usually rich client applications (single-page applications or mobile apps), built on On top of the cloud service ecosystem, including databases (Parse, Firebase), account systems (Auth0, AWS Cognito), etc. These services were originally called Baas (Backend as a Service).
Serverless can also refer to this situation: part of the server logic of the application is still completed by the developer, but unlike the traditional architecture, it runs in a stateless computing container, driven by events, and has a short life cycle (even only one call) ), completely managed by a third party. This situation is called FaaS (Functions as a service). AWS Lambda is currently one of the popular FaaS implementations.
According to Martin Fowler's description, the relationship between FaaS, BaaS and Serverless can be summarized as shown in the figure below.
Serverless architecture composition
From the perspective of the structure of Serverless, Serverless = FaaS + BaaS is a generally recognized concept; from the perspective of the characteristics of Serverless, Serverless runs in a stateless computing container, triggered by events, and has elastic scaling and pay-as-you-go etc. Ability, so that users do not need to spend more energy on the server, but pay more attention to the business itself.
The definition of Serverless from different angles
Serverless workflow
In actual production, the serverless architecture is usually a combination of FaaS and BaaS, and has the characteristics of elastic scaling and pay-as-you-go.
When a developer wants to develop a project:
- Usually it is only necessary to select a familiar programming language according to the Runtime provided by the FaaS provider, and then proceed with project development and testing (step 1 in the figure)
- After completion, upload the code to the FaaS platform (step 2 in the figure)
- After uploading, you only need to use API/SDK; or some cloud event source (step 3 in the figure)
- Trigger the function uploaded to the FaaS platform, and the FaaS platform will flexibly execute the corresponding function according to the triggered concurrency (step 4 in the figure)
- Finally, the user can pay according to the actual resource usage (step 5 in the figure)
Serverless workflow
Let's look at an example of a Web application. Under normal circumstances, some Web applications are traditional three-tier C/S architecture. For example, a common e-commerce application assumes that its server uses Java and its client uses HTML/JavaScript.
Traditional Web application three-tier C/S architecture
Under this architecture, the server is only a cloud server, which carries a large number of business functions and business logic. For example, most of the logic in the system (identity verification, page navigation, search, transaction, etc.) is implemented on the server. Transform it into a serverless application form.
Serverless application form diagram
In the serverless application form, the authentication logic in the original application is removed, and a third-party BaaS service is used (step 1 in the figure above); the client is allowed to directly access part of the database content, and this part of the data is completely hosted by the third-party , Some security configurations will be used to manage the client's permission to access the corresponding data (step 2 in the figure above); the first two points have already implied a very important third point: some of the logic of the previous server has been transferred to the client, such as keeping User session, understand the UX structure of the application, obtain data and render the user interface, etc.
In fact, the client has gradually evolved into a single-page application (step 3 in the above figure); there are still some tasks that need to be kept on the server, such as heavy computing tasks or operations that require access to large amounts of data. Here we take "search" as an example. The search function can be separated from the continuously running server and implemented in FaaS, receiving requests from the API gateway (explained in detail later) and returning responses. This server function can read product data from the same database as the client. The original server is written in Java, and AWS Lambda (assuming the FaaS platform used) also supports Java, so the original search code can be slightly modified to implement this search function (step 4 in the figure above); Rewrite the "buy" function into another FaaS function. For security reasons, it needs to be implemented on the server instead of on the client. It is also exposed to external use via the API gateway (step 5 in the figure above).
In the entire project, serverless users only care about the business logic in the function. As for the authentication logic, API gateway, and database, some products/services that were originally on the server side are all provided by cloud vendors. In the entire project development, launch and maintenance process, users do not need to pay attention to server-level maintenance, nor do they need to invest in operation and maintenance resources for the peaks and valleys of traffic. All of these security, flexibility, and operation and maintenance work are required. Cloud vendors are given unified processing/scheduling. What users need to pay attention to is whether their business code meets their business requirements. At the same time, under the serverless architecture, users do not need to make additional expenditures for idle resources. The pay-as-you-go model of the serverless architecture As well as flexible scalability, low server-side operation and maintenance/free operation and maintenance capabilities, serverless users' resource costs, labor costs, and overall R&D efficiency can be greatly improved, so that the performance, safety, and stability of the project are greatly guaranteed .
Serverless supporting services
1. Developer tools
Serverless developer tools include command line tools, editor plug-ins, and other tools.
In general, there are two types of command line tools: vendor-side tools and open-source construction tools. For example, AWS Lambda's SAM CLI, Alibaba Cloud Function Computing's Funcraft, etc. are typical one-party tools. This type of tool is characterized by a very high degree of matching with manufacturers and products, some features are supported relatively quickly, and the disadvantage is that it is relatively conservative. Serverless Devs and Serverless Framework are typical three-party tools. Both of these tools support FaaS products from cloud vendors such as AWS Lambda, Alibaba Cloud Function Computing, and Tencent Cloud Cloud Functions.
From the perspective of client performance, they are both serverless developer tools, componentized command-line tools, and all support multi-cloud; from the morphological point of view, Serverless Framework pays more attention to the direction of deployment and operation and maintenance, and Serverless Devs pays more attention to Serverless applications. Full life cycle. At the same time, Serverless Devs adds a visual interface compared to Serverless Framework.
Serverless Devs GUI home page
As shown in the figure, through this interface, users can quickly deploy applications.
Serverless Devs GUI visual Yaml edit page
Users can quickly manage serverless-related resources on the cloud, as shown in the figure.
Serverless Devs GUI project management page
Azure Functions also provides a Visual Studio Code plug-in, as shown in the figure below. The Azure Functions project template in Visual Studio can be used to create projects, and the created projects can be published to function apps in Azure. Users can use the function app to group functions into a logical unit to facilitate management, deployment, and sharing of resources.
VSCode plugin provided by Azure Functions
Alibaba Cloud provides the VSCode plug-in at the developer tool level, as shown in the figure.
At the same time, Alibaba Cloud Function Computing also provides the Cloud Toolkit tool, which enables running and downloading cloud functions in the local Jet Brains IDE, and creating and uploading local functions. Taking IntelliJ IDEA as an example, its function management interface is shown in the figure below.
Alibaba Cloud Function Computing VSCode plug-in function management interface
2、Serverless Workflow
Serverless Workflow is a fully managed cloud service used to coordinate the execution of multiple distributed tasks.
As shown in the figure, in the serverless workflow, users can arrange distributed tasks in sequence, branch, and parallel. Serverless workflow will reliably coordinate tasks according to the set steps, track the state transition of each task, and execute user-defined retry logic when necessary to ensure the smooth completion of the workflow.
Serverless workflow monitors the execution of tasks by providing logging and auditing, making it easy for users to diagnose and debug applications. Serverless workflow simplifies tedious tasks such as task coordination, state management, and error handling required to develop and run business processes, allowing users to focus on business logic development.
Serverless workflow example
Serverless workflow can coordinate distributed components to orchestrate applications written in different infrastructures, different networks, and different languages, and smooth the gap in the transition from hybrid cloud, proprietary cloud to public cloud, or from monolithic architecture to microservice architecture. Serverless workflow provides a wealth of control logic, such as sequence, selection, parallelism, etc., allowing users to implement complex business logic with less code. Serverless workflow manages the process state for users and provides built-in checkpoint and playback capabilities to ensure that the application is executed step by step as expected. Error retry and capture allow users to deal with errors flexibly. Serverless workflow is charged according to the number of conversions of the actual execution steps, and no more fees are charged at the end of the execution. Serverless workflow automatically expands, freeing users from managing hardware budgets and expansion.
Serverless applications
The observability of serverless applications is of concern to many users. Observability is measured by judging the internal state of the system through external performance. In application development, observability helps users judge the internal health of the system. When there is a problem in the system, it helps users locate, troubleshoot, and analyze problems; when the system is running smoothly, it helps users assess risks and predict possible problems. . In serverless application development, if the concurrency of functions is observed to continue to increase, it is likely that the business promotion team is working hard to rapidly expand the scale of the business. In order to avoid reaching the concurrency limit threshold, developers need to increase the concurrency in advance. Taking Alibaba Cloud Function Computing as an example, Alibaba Cloud Function Computing provides multiple dimensions at the observability level, including Logging, Metric, and Tracing.
Function calculation observability overall chart
In the console monitoring center, we can view the overall metric, the service-level metric, and the metric of each function. In addition, we can also see the request record of the current function.
Function calculation observability function request record
According to different request records, you can view the detailed information of the function, as shown in the figure.
Function calculation observability request-level record details
In addition to the function log and other information can be viewed in the monitoring center of the console, we can also see the detailed log information of the function on the function details page.
Function calculation log view
Tracing related information is shown in the figure.
Function Computation Observability Tracing Related Information
About the author:
Liu Yu (Jiang Yu) is a Ph.D candidate majoring in electronic information at National University of Defense Technology, Alibaba Cloud Serverless product manager, Alibaba Cloud Serverless cloud evangelist, and a distinguished lecturer of CIO Academy.
new book recommendation
This book will introduce to readers what the serverless architecture is, how to get started with the serverless architecture, the application of the serverless architecture in different fields, and how to develop a serverless from scratch through multiple open source projects, multiple cloud products from multiple cloud vendors, and multiple channels. Application etc. This book can help readers integrate the Serverless architecture into their own field, put the Serverless project on the ground, and obtain the technical dividends brought by the Serverless architecture.
Click to buy immediately:
http://product.m.dangdang.com/29250860.html?unionid=P-113341856m-:-dd\_1
Copyright Statement: content of this article is voluntarily contributed by Alibaba Cloud real-name registered users. The copyright belongs to the original author. The Alibaba Cloud Developer Community does not own its copyright and does not assume corresponding legal responsibilities. For specific rules, please refer to the "Alibaba Cloud Developer Community User Service Agreement" and the "Alibaba Cloud Developer Community Intellectual Property Protection Guidelines". If you find suspected plagiarism in this community, fill in the infringement complaint form to report it. Once verified, the community will immediately delete the suspected infringing content.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。