In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Click to download "different double 11 Technologies: cloud Native practice in Alibaba economy"
This article is excerpted from the book "different double 11 Technologies: cloud Native practice in Alibaba economy". Click on the picture above to download it!
Author | Wu Tianlong (Mu Wu) Ali Cloud function Computing expert
Introduction: Mini Program is a lightweight and fast iterative mobile application, which puts forward higher requirements for developers from development to launch. Using function computing, developers do not need to care about the construction, operation and maintenance of back-end services, and only need to write functions to provide stable, reliable and scalable services for Mini Program. And with the increase of Mini Program visits, function calculation can automatically and quickly stretch, even to cope with the double 11 activity peak can also be as smooth as silk.
Since the first batch of Mini Program launched in 2017, more and more mobile applications have been presented in the form of Mini Program. Mini Program has the advantage of being within reach and leaving after use, which greatly reduces the burden on users and makes Mini Program widely spread. In Alibaba, Mini Program is also widely used on Taobao / Alipay / nailing / Gaode and other platforms. For example, this year's Singles' Day, most of the activities that people participate in on Taobao / Tmall are provided through Mini Program.
A Mini Program can be divided into the client and the server: the client includes the display and interaction logic of the interface; the server includes data processing and analysis.
In order to support a large number of Mini Program, the challenges that the platform faces on the server side are:
A large number of Mini Program is inactive, the traditional way of at least one server will cause a waste of resources; in the peak period of activity, the call of Mini Program surges sharply, which requires the server to be able to scale quickly.
For Mini Program scenarios, Aliyun provides a complete Mini Program solution: mini Program Cloud. The effective use of resources and elastic scaling is one of the core competencies provided by Mini Program Cloud, which is backed by Ali Cloud function computing service. Function computing is a fully managed Serverless computing service that allows developers to build reliable, flexible and secure services without managing infrastructure such as servers, as long as they write and upload code. The following is the core technology of analytic function calculation in auto scaling, taking the double 11 Mini Program scenario as an example.
Mini Program architecture
Let's take a look at what the technical architecture of Taobao Mini Program looks like:
Users click on the store activity in Mobile Taobao and enter Mini Program. The interface and interaction are provided by the Mini Program client; when users participate in activities and request or send data from the server, the client initiates a function call; the function call first goes through Taobao access gateway to carry out the necessary authentication, and then calls to the mini program cloud; the user's function code is executed in Mini Program Cloud, and the user can implement custom business logic.
With the rich scalability provided by Mini Program Cloud, users can easily build complete e-commerce applications:
Data storage: storage of structured data; file storage: storage of text / picture / video files; e-commerce services: access to user information / creation of payment transactions; statistical analysis: automatic statistics of Mini Program usage information and user analysis to support business decisions.
As you can see, the function is the core of the business logic of Mini Program. It combines the basic capabilities of the cloud and provides service capabilities to the client. If the function capacity becomes a bottleneck, it will affect the operation of the whole Mini Program.
In such an architecture, to support a large number of Mini Program, functions need to be able to do the following:
One is to be online at any time to support Mini Program ready to use; the other is to scale to cope with the sudden increase in Mini Program visits. In order to do the above two things, let's take a look at the technical architecture of function computing: the architecture of function computing.
Several of the core components have the following functions:
API service: function computing gateway to achieve authentication / flow control and other functions; resource scheduling: allocation and management of computing resources for function calls, responsible for scheduling efficiency and performance; function execution engine: the environment in which the function code is executed to achieve security and isolation.
Based on this architecture, how does function computing solve the challenge of Mini Program platform mentioned above? Next, let's analyze them one by one.
1. Cold start
When a user creates a function to upload code, the function calculation only saves the code package to OSS without allocating computing resources, so function calculation can support a huge amount of Mini Program.
When a function is called for the first time, the function calculation allocates computing resources, downloads the function code, and loads and executes the code. This process is called cold start, and the function calculation optimizes the cold start time on the system side to within 200ms through a large number of optimizations. Therefore, even if it is cold Mini Program, it can be quickly and immediately used when called for the first time.
two。 Elastic expansion
When Mini Program continues to call, the load increases gradually or suddenly, how does the function calculation deal with it?
The "resource scheduling" module calculated by the function will accurately manage the state of each instance. When the request arrives, it first checks whether there are free instances to serve, and if there is no request, it will enter the waiting queue. When an idle instance is released, the request can be processed in a timely manner.
At the same time, the scheduler creates a new instance in the background and can also serve the request when the new instance is ready. Under this strategy, the requested P95 delay is stable when the load increases twice as fast. For more details, please refer to our blog post.
The above is the usage and delay monitoring data of a Taobao Mini Program.
It can be seen that there is an instantaneous peak in TPS during the hour activity, but there is no obvious fluctuation in P95 delay. This is because when the request peak comes, the function calculation can quickly and flexibly scale to create new instances, while using existing resources to do a certain buffer, so that the whole climbing process can be relatively smooth.
3. Reserved instance
For some "second kill" scenarios, a large number of computing resources are required to be provided instantly. At this point, it is not enough to rely on real-time auto scaling:
First, the cold start time, even 200ms, is too slow for the second-kill scenario; second, the underlying computing resources will be subject to flow control when the capacity is expanded.
For this scenario, function calculation provides the function of reserving instances. By using reserved instances, users can reserve resources in advance for some predictable activities and completely eliminate cold starts.
Different from the traditional server-based approach, users do not need to reserve resources by peak, but can combine the mixed mode of reserved instances and by-quantity instances: the request is processed by reserved instances first, and when the reserved instances are full, more instances will be automatically flexibly scaled out to process the request.
Due to a certain resource base, combined with scheduling optimization, the impact of cold start-up of per-quantity instances is greatly reduced. This is the use of function computing flexibility to achieve a good balance between performance and cost.
Summary
Mini Program is a lightweight and fast iterative mobile application, which requires high efficiency of Mini Program developers.
With the increase of the number of visits or the sudden increase of visits during the activities after the launch of Mini Program, it is also a great test for the stability and flexibility of the back-end services. The function can be run by uploading the code, which greatly improves the development efficiency of the back-end service; the elastic scaling of the mixed mode makes it easy to cope with load changes. These characteristics make function computing a good choice to support Mini Program platform.
Developers who are interested in function computing can click this free trial)!
The highlight of this book
In the practice of Shuang 11 super large K8s cluster, the problems and solutions encountered are described in detail. The best combination of Yunyuan biochemistry: Kubernetes+ container + Shenlong, to achieve the technical details of the core system 100% on the cloud. Double 11 Service Mesh super large-scale landing solution
"Alibaba Cloud Native focus on micro-services, Serverless, containers, Service Mesh and other technology areas, focus on cloud native popular technology trends, cloud native large-scale landing practice, to be the best understanding of cloud native developers of the technology circle."
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.