How to 0 transform a single / micro service application into a serverless application


How to 0 transform a single / micro service application into a serverless application

Author Chen Tao (Bi Shan)
Source|Alibaba cloud official account

1、 Natural cloud native serverless

1. Cloud primary Era

With the development of container technology represented by docker, CNCF foundation and k8s in 2013, cloud native began to be well known by developers. There are two stages before the cloud native era: one is to build a self IDC room, and the other is to simply move the original applications to the cloud. The self built IDC room is difficult to obtain high availability, high scalability, operation and maintenance efficiency improvement and other capabilities; The second stage is the cloud computing era, which has made some progress compared with IDC, but most of them are still using the cloud relatively primitive, so it is difficult to make good use of the cloud. The resources at this stage are nearly unlimited, but the methods based on virtual machines and various self built services need to be improved.

How to 0 transform a single / micro service application into a serverless application

Cloud native era refers to the design of applications, taking into account that applications will run in the cloud environment in the future, and making full use of the advantages of cloud resources, such as the flexibility and distribution of cloud services. As shown in the figure above, the primary cloud can be divided into several parts:

everythingCloud native technology, including container, k8s, microservices and Devops. These technologies are just tools. To really make good use of these technologies, we need some best practices and combinations, that is, cloud native architecture.

Cloud native architectureIt is a collection of architecture principles and design patterns based on cloud native technology. It is some guiding principles. For example, observability is required. Subsequent flexibility can only be done on the premise of observability, including the construction of high availability and the sinking of infrastructure. It is hoped to maximize the stripping of non business code, Under the guidance of such technology and architecture design, cloud native applications can be designed.

Cloud native applicationWith the characteristics of light weight, agility and high automation, it can give full play to the advantages of cloud and better adapt to the development and changes of business in the era of modern digital transformation.

2. Serverless natural cloud native

How to 0 transform a single / micro service application into a serverless application

Why is serverless native to the natural cloud? Although serverless appeared earlier than cloud native, we go back. AWS took the lead in launching the first generation of serverless product lambda, which has the characteristics of billing on request and extreme scalability, and is very in line with the definition of cloud native, such as infrastructure sinking. In lambda, there is no need to manage the server. It will scale the server according to the request, realizing a high degree of automation; It also organizes code in the form of functions, which are lighter and faster to deliver than applications. However, the disadvantage of this mode is that the transformation cost is high, because many applications are originally a huge monomer or micro service application, which is difficult to transform into a function mode.

3. Recognize SAE

The concept of serverless and related products have been launched for almost seven years. In this process, the cloud native technology is also maturing, including docker, k8s, etc. Alibaba cloud began to think about another form of serverless in 2018, namely, serverless application, that is, SAE. It was launched in September 18 and has been commercialized for 19 years. So far, it has gone through three years.

How to 0 transform a single / micro service application into a serverless application

SAE features:

  • Immutable infrastructure, observable, automatic recovery

Based on the k8s sled, it represents the immutable infrastructure such as image and observable and automatic recovery. If the request fails, it will automatically cut off the flow or restart the instance.

Hosting server resources does not require users to operate and maintain the server themselves. At the same time, it also has the ability of extreme flexibility and extreme cost.

  • Easy to use, 0 transformation and integration

As shown in the figure above, the top layer is the customer perception layer, which is the product form of apaas and an application of PAAS. After more than three years of practice, it has finally achieved the effect of making users really easy to use and 0 transform, and has done a lot of integrated integration.

How to 0 transform a single / micro service application into a serverless application

SAE, a product with k8s as its base, serverless characteristics and apaas as its form, fully conforms to the characteristics of cloud native. At the technical level, the bottom layer uses containers and k8s to integrate micro services, including various Devops tools. At the architecture level, because the underlying layer depends on these technologies, it is very convenient for users to design their own application practices in accordance with the principles of cloud native architecture, so that customers’ applications can maximize the dividends of cloud native, realize the lightweight, agility and high automation of applications, and greatly reduce the threshold of entering the cloud native era.

How to 0 transform a single / micro service application into a serverless application

SAE product architecture diagram

SAE is an application-oriented serverless PAAS,0 transformation 0 threshold 0 vessel foundationIs its feature, which makes it very convenient for users to enjoy the technical dividends brought by serverless, k8s and microservices. At the same time, it also supports multiple micro service frameworks, multiple deployment channels (including UI deployment / cloud effect / Jenkins / plug-in deployment of its own products), and multiple deployment methods (including war / jar / image deployment).

The bottom layer is an IAAs resource layer, and the top layer is a k8s cluster. For users, these are transparent. They do not need to purchase servers or understand k8s. The next layer has two core capabilities: application hosting and microservice governance. Application hosting is the application life cycle, and microservice governance is service discovery and graceful offline, These are well integrated in SAE.

The core features of SAE can be summarized into three: one is 0 code transformation, the other is 15s elastic efficiency, and the third is 57% cost reduction and efficiency improvement.

2、 SAE design philosophy

1. Kubernetes base

How to 0 transform a single / micro service application into a serverless application

  • container

In the k8s container choreography ecology, the most basic is the container or image. Relying on the image, the user is equivalent to realizing the immutable infrastructure. Its advantage is that the image can be distributed and copied, which is equivalent to realizing portability without vendor binding. In addition, for users who are not familiar with the image or do not want to feel the complexity, we also provide war / jar level deployment, which greatly reduces the threshold for users to enjoy dividends.

  • End state oriented

In the traditional operation and maintenance field, many problems are difficult to solve. For example, the server suddenly has a high load or high CPU for various reasons. At this time, a large number of manual operation and maintenance operations are usually required in the traditional field. In the k8s field, combined with observability and health inspection, automatic operation and maintenance can be realized only by configuring liveness and readiness, K8s will automatically cut flow and automatically reschedule, greatly reducing the operation and maintenance cost.

  • Resource hosting

Not only the ECS machine is hosted, but k8s is also internally hosted for operation and maintenance. Customers do not need to buy servers or k8s or operation and maintenance k8s, or even understand k8s, which greatly reduces the entry threshold and salary burden of customers.

2. Serverless feature

How to 0 transform a single / micro service application into a serverless application

  • Ultimate elasticity

We have achieved end-to-end 15 seconds, that is, a pod can be created in 15 seconds to start the user’s application. In terms of elasticity, we have basic index elasticity (such as CPU, memory, etc.), business index condition elasticity (such as QPS, RT, etc.) and timing elasticity. If the elasticity index is manually set, there are still some thresholds and burdens, because the customer does not know how much the index should be set. In this context, we are also considering intelligent elasticity, automatically help the user calculate the elasticity index and recommend it to the user, so as to further reduce the threshold.

  • Lean cost

SAE eliminates the cost of resource hosting and operation and maintenance. Before that, customers need to operate and maintain a large number of ECS servers. When security upgrading and vulnerability repair are required, especially high-density deployment, the cost will be very high. In addition, SAE billing mode is based on minute billing, and users can fully realize lean cost. For example, the capacity is expanded to 10 instances in one hour during the business peak, and becomes 2 instances after the peak.

  • Language enhancement

In the field of flexibility, we have made some targeted language enhancements. For example, in combination with Alibaba’s large-scale Java application practice, Alibaba’s JDK dragonwell11 can improve the startup speed of Java applications by 40% compared with other open source jdks. In the future, we will explore more possibilities in other languages.

3. (application) PAAS product form

How to 0 transform a single / micro service application into a serverless application

  • Application Hosting

Application hosting is equivalent to the management of application life cycle, including application publishing, restart, capacity expansion, gray publishing, etc. its mind is the same as that of everyone using applications or other PAAS platforms, and the threshold for getting started is very low.

  • Integrated integration

Because there are hundreds of cloud products, if you want to use each one well, it is also an additional cost. Therefore, we have integrated the most commonly used cloud services, including basic monitoring, business monitoring, arms, NAS storage, SLS log collection and other aspects, so as to reduce the threshold for users to use the products.

In addition, we have also made additional micro service enhancements, including hosting registration center, elegant online and offline and micro service governance. Because the use of micro services usually requires a registration center. SAE has a built-in hosting registration center. Users do not need to re purchase. They can register applications directly, further reducing the user threshold and cost.

SAE combines these capabilities so that users can basically realize 0 transformation and migration when migrating traditional monomer applications or microservice applications, and enjoy the technical dividends behind this product.

3、 SAE technical architecture

1. SAE technical architecture

How to 0 transform a single / micro service application into a serverless application

The technical architecture behind the k8s hosted by SAE is shown in the figure above. On one host, the top layer is SAE’s PAAS interface, the second layer is k8s’s master (including API server), and the bottom layer is the host of k8s’s real running resources. These are completely hosted by SAE, Users only need to create pod resources in their own VPC or network segment and make a connection to realize the normal operation of the application.

There are two core issues:

First, anti penetrationFor example, our pod or container uses traditional container technology such as docker. Running two users a and B of the public cloud to one physical machine actually has a very high security risk. User B is likely to invade into user a’s container to obtain user information. Therefore, the core of this is to limit the user’s ability and prevent them from escaping.

Second, network connectivity or cloud system connectivity, we need to connect with the user’s network system so that the user can easily connect with his security group, security rules, RDS, etc. This is also a core problem.

2. Safety container

How to 0 transform a single / micro service application into a serverless application

Here we will expand the problem of anti escape. The table above is a widely discussed security container technology. The simple understanding of security container is the idea of virtual machine. If the traditional container technology such as docker is used, it is difficult to do a good job in security protection or isolation, and the security container can be understood as a lightweight virtual machine, which has both the startup speed of the container and the security of the virtual machine.

At present, the security container has gone beyond security, including not only security isolation, but also performance isolation and fault isolation. Taking fault isolation as an example, if you use docker container technology and encounter some kernel problems, it may affect other users due to the failure of one docker container, and the whole host may be affected, If the safe container technology is adopted, there will be no such problem.

SAE adopts Kata security container technology. In terms of time and open source community, Kata is a combination of runv and clear container projects, which is more mature than firecracker and gvisor solutions.

4、 SAE best practices

Best practice 1: low threshold microservice architecture transformation

How to 0 transform a single / micro service application into a serverless application

Customers familiar with microservices know that if they want to operate and maintain a set of microservice technology architecture by themselves, many factors need to be considered, not only at the open source, framework level, but also at the resource level and subsequent troubleshooting, including registration center, link tracking, monitoring, service governance, etc., as shown on the left side of the figure above. Under the traditional development mode, These capabilities need to be managed and operated by users themselves.

In SAE, users can hand over some business independent features to SAE. Users only need to pay attention to their own business, including user center and group center of microservices, and integrate with SAE’s CI / CD tools to quickly realize microservice architecture.

Best practice 2: one click start stop development and test environment to reduce cost and increase efficiency

How to 0 transform a single / micro service application into a serverless application

Some large and medium-sized enterprises have multiple sets of test environments. These test environments are generally not used at night. In ECs mode, these application instances need to be kept for a long time, and the cost of idle waste is relatively high.

If the namespace can be combined in SAE, such as the ability to start and stop with one click or start and stop regularly, all applications of the test environment can be built in the namespace of the test environment, and then all instances of the test environment namespace can be started at 8:00 in the morning and stopped at 8:00 in the evening. The time period after the stop will not be charged at all, Allows users to minimize costs.

According to the calculation, in the extreme case, it can basically save 2 / 3 of the user’s hardware cost, and there is no need to pay other operation and maintenance costs. Just configure the regular start and stop rules.

Best practice 3: accurate capacity + extremely flexible solution

How to 0 transform a single / micro service application into a serverless application

In this year’s epidemic situation, a large number of students conduct online education at home. Many customers in the online education industry are facing a seven or eight fold surge in business traffic. If they are based on their own operation and maintenance ECS architecture, users need to upgrade the architecture in a very short time, not only the operation and maintenance architecture, but also the application architecture, This is a great challenge to the cost and energy of users.

It can be much simpler if it relies on a variety of integration in SAE and a highly automated platform such as the underlying k8s. For example, the capacity and water level can be evaluated in combination with PTS compression tool; For example, if there is a problem with pressure measurement, it can be combined with basic monitoring and application monitoring, including call chain and diagnostic report. It can analyze where the bottleneck is and whether it can be solved in the shortest possible time; If it is found that it is a bottleneck that is difficult to solve, the application high availability service can be used to realize current limiting and degradation, so as to ensure that the business will not collapse due to sudden flood peaks.

Finally, SAE can configure corresponding elastic strategies according to the pressure measurement model, such as CPU memory, RT or QPS, and set industry strategies when there is a capacity model, so as to achieve the effect of very fitting the actual usage, and achieve low cost and maximum upgrading of the architecture.

5、 Summary

How to 0 transform a single / micro service application into a serverless application

Digital transformation has penetrated into all walks of life. Whether due to time development or epidemic situation, in digital transformation, enterprises should have the ability to apply cloud well to meet the challenges of rapid business changes and high peak and high traffic scenarios. This process includes several stages: rehost (new hosting), re platform (New platform), refactor (New Architecture), With the deepening of architecture transformation, the higher the value of the cloud that enterprises can obtain, and the cost of migration and transformation will also rise. If the application is simply hosted on the cloud, it is difficult to obtain the elasticity of the cloud, and it is still difficult to deal with problems in time.

Through SAE, we hope that users can enjoy the value dividend of serverless + k8s + microservices with 0 transformation, 0 threshold and 0 container foundation, and finally help users better face business challenges.

This article is compiled from [serverless live series live broadcast] on January 29
Live view link:

Serverless Ebook Download

Highlights of this book

  • Starting from the architecture evolution, this paper introduces the serverless architecture and technology selection, and constructs the serverless thinking;
  • Understand the operation principle of the popular serverless architecture in the industry;
  • Master the top 10 real landing cases of serverless, learn and use them flexibly.

Download link