In the past few years, Serverless has developed rapidly, accompanied by the evolution and practice of mini-programs, mobile, and front-end integration. Because of this, from cloud computing to the front end, many developers are extremely concerned. This article introduces the Serverless practice of Tencent Cloud CloudBase, which is believed to be of benefit to developers who pay attention to Serverless and r&d mode.
What exactly is Serverless?
In the country, Serverless is often referred to as “service-less computing”. Serverless, however, is not a concrete framework, code base, or toolset. Rather, it is a set of theoretical ideas designed to reduce service operation/maintenance costs for developers.
To simplify the cost of understanding for developers, the industry defines Serverless in a way that combines the cloud computing industry:
Serverless = FaaS + BaaS
FaaS: Function as a Service.
For FaaS, there are already many mature vendors offering online products, such as:
- AWS Lambda, the first FaaS cloud product, has good interaction with AWS cloud products and is widely used by developers.
- Azure Functions, Microsoft’s public cloud function computing product, was released later than AWS Lambda.
- Google Cloud Functions, a public Cloud computing product from Google, has deep interaction with Google Firebase.
- Serverless Cloud Fucntion, a public Cloud computing product from Tencent Cloud, is deeply integrated with the Cloud development of Tencent Cloud.
BaaS: Backend as a Service.
In the case of BaaS, the coverage is much broader and needs to address all back-end scenarios except computation during Serverless landing, such as database services, message queues and storage services. When using BaaS service, developers no longer need to perceive the back-end service operation and maintenance, put forward service requirements, and enjoy the service. For example, the Database Service is called DBaaS (Database as a Service). In traditional scenarios, the developer’s o&M team is concerned with the details of database o&M. With DBaaS, the developer only needs to focus on the business logic.
What is cloud development?
Cloud Development (TCB) is a cloud native integrated development environment and tool platform provided by Tencent Cloud. It provides developers with highly available, automatic and flexible expansion of back-end cloud services, including computing, storage, hosting and other serverless capabilities, which can be used for cloud integrated development of various end applications (small programs, Public account, Web application, Flutter client, etc.) to help developers build and manage back-end services and cloud resources in a unified manner, avoiding tedious server construction, operation and maintenance during application development. Developers can focus on the implementation of business logic, with lower development threshold and higher efficiency. Technical documentation: Cloudbase.net
Tencent cloud development in Serverless what kind of results?
In order to enable application developers to implement their ideas more efficiently, Tencent Yunyun Development, as the earlier team of Serverless implementation practice in China, combined with the concept of Serverless, has created a set of multi-terminal one-stop application development platform CloudBase that serves developers. And achieved multi-terminal support, greatly saving resource cost, free operation and maintenance and other achievements verification.
At present, Tencent Yunyun development services 500,000 developers, covering areas including applets, Web applications and terminal applications. Developers can quickly build their business logic based on cloud development platform CloudBase, freeing up creativity.
CloudBase gradually found the shortcomings of FaaS in Serverless landing practice
Based on cloud development capabilities of CloudBase, developers only need to pay attention to their core business logic, and cloud development will deal with the availability, reliability, fault handling and recovery of background services and other distributed problems.
Here is a product matrix for CloudBase:
Cloud function is one of the basic services of Cloud development CloudBase and the implementation of FaaS in Serverless concept. However, as cloud development CloudBase continues to serve a variety of developers in the process, cloud functions have also exposed some shortcomings in solving user business scenarios. It mainly includes the following aspects:
01**** Renovation cost
In the cloud model, developers need to make a series of cloud adaptation changes to move their existing business to cloud development. In particular, part of the developer’s business needs to be based on the background resident mode to run effectively, while the features of cloud functions such as event triggering and recycle cannot support this important demand of developers.
02**** Linguistic ecological constraints
Cloud functions need to provide different Runtime versions for different languages, such as Node.js scenarios. As the version is constantly updated and iterated, the platform needs to adapt to the new Runtime version. In addition, different development languages often have many supporting frameworks. Such as Koa and Express of Node.js ecosystem, these frameworks often rely on some mechanism of system platform, and cloud functions themselves need extra cost to adapt to these frameworks, and the compatibility of frameworks will greatly affect the willingness of relevant language developers to use.
3 * * * * performance
The on-demand use of cloud functions, which incur computing costs only when the request is actually triggered, greatly reduces the developer’s operation and maintenance costs, but also brings startup latency, also known as the “cold start” problem.
In order to solve this cold start problem, cloud functions can be optimized by methods such as delayed destruction after initial start and resource reservation. However, for some businesses with high performance requirements, cloud functions cannot provide services close to the traditional computing model, which also affects the willingness of developers to use cloud functions.
In order to complement the shortcoming of cloud function, Serverless cloud application is proposed.
The technical ideas behind the Serverless cloud application
What other options are there for Serverless computing carriers besides FaaS?
The answer is yes. At the Google Technology Conference in April 2019, Google Cloud announced that it would focus on vertical fields such as telecommunications, retail and finance, and cooperate with mature large enterprises. Aiming at such users’ problems such as limited language ecological support, excessive transformation cost and performance when using Serverless products, the Serverless container product CloudRun based on Knative is introduced.
Here’s a timeline of Google Cloud Run products:
What about the Knative idea behind CloudRun?
**Knative was proposed by Google to try to solve the problem that Kubernetes has a slightly higher threshold of entry, and this concept has been unanimously recognized by the industry. **Knative focuses on three key components: Build your application, provide traffic serving, and ensure that the application can easily produce and consume events. Here’s an architectural diagram that visually illustrates the relationship between Knative and Kubernetes:
How to implement Knative concept of Serverless cloud application?
Cloud development CloudBase Serverless cloud application is based on Knative to build the entire system, around Knative to carry out the actual implementation of relevant concepts. We will elaborate on CloudBase Serving, CloudBase Build, and CloudBase Cloud application ecology.
CloudBase Serving
- The URL to the container
When a user creates a service using the CloudBase Serverless cloud application, a CORRESPONDING URL is generated. The user can access the corresponding service through this URL. So how does this URL map to the corresponding container by version traffic management? The diagram below:
Multiple Revisions are allowed under the CloudBase service. Users can set the traffic for each version. The Router routes requests based on the traffic proportion to implement the customized grayscale policy for service dimensions.
- Enlarge shrinks to zero
In the Serverless scenario, we also allow users to set the minimum number of copies to 0. For some services that require resident services, developers can set the minimum number of copies to no 0, which can effectively cope with cold starts.
As you can see, each Revision corresponds to a set of Pod managed by Deployment.
Pod automatically reports metrics data to Autoscaler, which modifies the number of replicas in Deployment based on the volume of requests and resource usage for automatic scaling. An important feature of the Serverless container is that it scales to 0, meaning that it automatically destroys all pods when there is no traffic to the application.
Activator comes in order to handle 0→1. When a Pod after some Revision shrinks to 0, the Route’s traffic points to the Activator, which automatically pulls the Pod when it receives the request and forwards the traffic to the Activator.
CloudBase Build
CloudBase provides three capabilities for cloud application delivery. Users can deploy Serverless cloud applications using any of the three methods: image, source code +Dockerfile, and source code.
The following three ways of landing practice:
Scheme selection: Considering that Knative Build is still undergoing rapid evolution (from Knative Build to Tekton Pipeline), CloudBase Build is temporarily constructed and delivered using the existing Build pipeline capability of Tencent Cloud.
- Mirror images
Users can use the existing image or locally generated image to push the image to Tencent cloud private image warehouse through the docker push native command, and then the CloudBase cloud application can be deployed and run.
- The source code + Dockerfile
Users can use source code +Dockerfile to deploy and run cloud applications. Source code +Dockerfile way to support local code upload, as well as cloud code (GitHub/GitLab/Coding, etc.) authorization pull deployment operation. In this mode, developers no longer need to care about how the image is built, CloudBase BuildServer will build the image in the cloud.
- The source code
Dockerfile still needs a certain threshold of entry, we have been thinking about whether there is a way to further reduce the threshold of users to use, launched a source code based approach. Users only need to write source code in the CloudBase Framework and use the CloudBase CLI tool to build and deploy the cloud.
CloudBase Cloud application ecology
To facilitate the developers of CloudBase cloud applications, CloudBase cloud applications will also be compatible with the CloudBase ecosystem (such as CloudBase Server SDK, CloudBase Cloud call, CloudBase Cloud payment, etc.).
When a cloud application is combined with the existing CloudBase ecosystem, users can reuse the capabilities of the existing CloudBase ecosystem.
As an example, let’s say a user’s website can be accelerated by putting static resources into static hosting. Dynamic resources are put into cloud applications to drive traffic. And the code does not need to implement cross-domain access Settings. Cloud applications and cloud functions can be accessed by the same domain name.
This is just a scenario of ecological combination. Based on the ability of cloud functions to be used in wechat ecology (cloud call, cloud payment), they can be used normally in cloud applications. I will not introduce them here, and I look forward to your exploration.
conclusion
CloudBase’s Serverless cloud application is a new generation of computing hosting platform launched by the cloud development team in the process of Serverless cloud integration practice. Based on the capabilities of the platform, developers can not only enjoy the advantages of free operation and maintenance brought by Serverless, but also focus on business and quickly implement ideas. Without the constraints of cloud mode (retrofit, cold start, Runtime limited), cloud applications will be a useful complement to the Serverless computing scenario.
Of course, in the cloud application mode, developers need to understand more concepts of computing services (image, framework, Dockerfile), which will be more important than the use of cloud functions. Cloud functions have more application scenarios in the rapid implementation of prototype verification, online lightweight ability.
In the traditional definition of Serverless concept, “Serverless=FaaS+BaaS”, which is a series of combinatorial relations, the interaction between each other is one-way, the behavior of FaaS one-way transmission to BaaS.
After the Serverless cloud application (Serverless Container) is added to the Serverless computing scenario, the concept of Container as a Service (CaaS) will gradually approach developers and Service developers.
Because the inclusion of the CaaS concept in the Serverless ecological equation will be changed to: “Serverless = FaaS+CaaS+BaaS”, but is this just an addition to the original concept? Considering the mutual transmission of computing power, the function relationship of Serverless will undergo essential morphological changes, as shown in the figure below:
Will CaaS redefine the semantics of Serverless (Serverless = FaaS+CaaS+BaaS) and how much of a combinatorial change will it bring to the Serverless ecosystem?
Let’s wait and see.
Cloud Development (TCB) is a cloud native integrated development environment and tool platform provided by Tencent Cloud. It provides developers with highly available, automatic and flexible expansion of back-end cloud services, including computing, storage, hosting and other serverless capabilities, which can be used for cloud integrated development of various end applications (small programs, Public account, Web application, Flutter client, etc.) to help developers build and manage back-end services and cloud resources in a unified manner, avoiding tedious server construction, operation and maintenance during application development. Developers can focus on the implementation of business logic, with lower development threshold and higher efficiency.
The product documentation: cloud.tencent.com/product/tcb
Technical documentation: Cloudbase.net
Technical exchange plus Q group: 601134960
Latest news follow wechat official account [Tencent Yunyun Development]