Introduction to Cloud’s self-developed Serverless product Function Computing FC is an event-driven fully managed computing service that perfectly meets Iraq’s needs and pain points for apps.
Beijing Millian Technology Co., Ltd. was established in 2015 and is a national high-tech enterprise. Its brand Yidui App was launched in 2018. It focuses on mobile dating and blind dates, and creatively integrates video, live broadcast and online matchmaking. The independent track of the video dating community provides a new social experience for singles. As of 2020, Iraq has 100 million registered app users, and it matches about 10 million online dating events every month, making it one of the most influential brands in the vertical field of video dating and social networking.
Business needs
With the rapid growth of Iraq's App business, the system scale and system complexity of core applications are also undergoing earth-shaking changes. The Iraqi App technical team maintains the technological advancement of the entire system architecture by introducing new technical means to better support business needs and reduce IT costs. Since its establishment, Iraq has completed many major upgrades to the core system architecture of App, involving important technologies such as microservices, containerization, distributed databases, big data, and artificial intelligence. Especially in the exploration of serverless technology, Iraq A lot of energy has been invested in the App to fully enjoy the value of rapid and elastic resource scaling in the cloud computing era.
In the business scenario of Iraq’s app, live video is the most important link. Based on the skeleton of live video, it can be integrated into a variety of innovative business models such as online matchmakers. This also puts forward extremely high requirements on the content security of live video. Regardless of whether it is performing intelligent analysis of live video content through AI technology or responding to regulatory requirements, it is necessary to intercept the video according to a fixed frequency after each live video stream starts, and generate the intercepted frame through a unified review service The pictures are processed.
In this requirement, the frame interception service bears the key responsibility. This service not only needs to intercept the frame of each live video stream through the FFmpeg command, but also needs to save the generated image to the object storage OSS and write the intercepted frame information To Kafka. In this way, the downstream frame-cutting service can pull the frame-cutting information from Kafka, and obtain the address of the picture in the OSS from the frame-cutting information, thereby completing the review of the picture. In this architecture, Kafka is introduced to relieve the load of the audit service during peak business periods through an asynchronous processing mechanism.
Business pain points
The FFmpeg frame cut command is very simple to use, but it is an operation that requires very high CPU computing power. According to many experiments conducted by Iraq on the App technical team, using ECS to deploy frame cutting services is a relatively cost-optimal choice. According to the fixed frequency of 1 frame cut per second, one ECS can support about hundreds of live video streams at the same time. In order to ensure resource reserves during peak business periods, Iraq has prepared a large number of ECS for App to deploy frame-cutting services. Like most Internet applications, there are peaks and troughs in Iraq’s load on the App. Such fluctuations have brought extremely high challenges to the overall resource planning of Iraq’s App. If the frame-cutting service is deployed according to a fixed ECS cluster scale , There will be two very obvious drawbacks:
In order to support business peaks, the cluster size must be evaluated according to the number of users during peak periods, which will cause huge waste during low peak periods.
In some scenarios, such as the holiday effect, there will be a sudden increase in business volume, and it may be necessary to temporarily expand the cluster. In this case, the expansion speed will often lag behind the growth rate of the business flow, resulting in degraded processing of some businesses. .
In order to save resource costs, Iraq has also explored a variety of elastic scaling strategies for App, such as deploying applications through elastic ECS instances and containerization, so that the cluster scale can dynamically adapt to changes in real business volume. However, the implementation of these strategies is relatively complicated, and the elastic scalability is relatively lagging. The fundamental reason is that in the traditional service architecture, an application keeps running for a long time after it is started. During the operation, it will concurrently process multiple business requirements. No matter how the business volume changes, the computing power occupied by this application will not There are essential changes.
Is there a straightforward way to pull up the corresponding computing power to undertake the task of intercepting the frame after a live video stream is opened, and automatically release the computing power after the video stream is closed? This method does not require application instances to be permanently resident, can achieve true on-demand distribution of computing resources, and does not require additional means to dynamically adjust the cluster size of the frame-cutting service. It is the most ideal solution.
As a representative of cloud-native serverless technology, Alibaba Cloud Function Computing FC has just achieved this idea.
What are the unique features of function calculation FC
Alibaba Cloud's self-developed Serverless product Function Computing FC is an event-driven fully managed computing service, which perfectly meets Iraq's needs and pain points for apps. Using functional computing, users do not need to purchase and manage infrastructure such as servers, just write and upload code. Function computing will automatically prepare computing resources, run tasks flexibly and reliably, and provide functions such as log query, performance monitoring, and alarms. With the help of function calculation FC, you can quickly build any type of applications and services, and you only need to pay for the resources actually consumed by the task.
Function calculation FC provides an event-driven calculation model, and the execution of functions is event-driven. The execution of the function can be triggered by the user of the function or by some other event source. You can create a trigger in a specified function. The trigger describes a set of rules. When an event meets these rules, the event source will trigger the corresponding function. For example, for HTTP triggering, a user's HTTP request can trigger a function; for OSS triggers, a new or modified file on OSS can trigger a function. In the video frame-cutting scene of Iraq to the App, the function only needs to actively trigger a frame-cutting function through the business program before each live stream starts to be pushed. Therefore, only minor adjustments are needed to the architecture of the previous frame-cutting service before it can be migrated to the functional computing platform to enjoy the value of Serverless.
Solutions and advantages
1. Runtime supporting multiple programming languages
When the Iraqi App technical team communicated with Alibaba Cloud about the Serverless solution for the first time, Alibaba Cloud’s technical staff recommended using Python language to implement the frame cutting function, because the function calculation FC provides for Node.js, Python, PHP, Java and other languages. Native operating environment, and scripting languages like Python can directly modify the scheduling code on the functional computing platform, which is very simple to use.
In fact, functional computing FC has no requirements for development languages, and any mainstream development language can be well supported. Through the Custom Runtime provided by the function calculation FC, a customized operating environment can be established for the task language. Custom Runtime is essentially an HTTP Server. This HTTP Server takes over all requests from the function computing system, including event calls or HTTP function calls.
2. Extreme flexibility and high availability
Because under the serverless architecture, each live video stream will pull up new computing resources to undertake frame-cutting tasks, so there is no need to use high-specification ECS instances to concurrently process multiple frame-cutting tasks at the same time. Through repeated tests, Iraq has adopted the most suitable function calculation example for the App to complete the frame cutting task of each video stream.
Function Computing FC has made a lot of optimizations in the startup of computing resources. With the cloudized resource pool, it can schedule a large number of computing instances within 100 milliseconds to carry the sudden increase in business traffic under special circumstances.
In order to further adapt to the business scenarios of Iraq's apps, the Alibaba Cloud Function Computing team also provides a regular warm-up method for Iraq's apps to maximize the performance of cold-start computing resources during peak business periods. Such extreme elastic scalability is the specialty of Serverless. The elastic scalability of traditional application architecture relies on the scheduling of underlying computing resources and complex initialization work. The startup speed of computing instances is far from this level.
Under normal circumstances, a normal elastic instance on Function Computing FC can run for 10 minutes. In addition, a performance instance is provided to cope with higher resource requirements. The runable time of the performance instance has also been increased to several hours. In Iraq’s screenshots of apps, a single instance does not need to have high performance, but it needs to be accompanied by a live video stream for long-term operation. Therefore, Alibaba Cloud has also appropriately released the runtime limit of elastic instances for Iraq’s apps. : Up to 1 hour.
For live broadcasts of more than 1 hour, it can also support: In the frame-cutting scene, when a function instance is about to reach the runtime limit, you only need to pull up a new function instance to relay the frame-cutting task. The normal operation of the frame-cutting service will not have any impact.
3. Save resources, reduce costs and increase efficiency
Function calculation FC realizes on-demand scheduling of computing resources and billing according to the amount. At the same time, it also further reduces the cost of use through the model of reserved instances. According to preliminary assessments, in the business scenario of live video capture, the serverless architecture based on function calculation FC can help Iraq to reduce the resource cost of App by more than 20%.
In addition, because function computing FC does not need to reserve computing resources, and does not need to maintain the underlying software and hardware, it greatly reduces operating costs and allows Iraq’s App technical team to focus more on the implementation of complex business logic. This is also one of the great values that Serverless technology brings to the majority of enterprises and developers.
Summarize
After successfully piloting serverless technology in the live broadcast scene, Yidui App continues to explore matching scenarios of serverless technology in more business areas. In the future, Iraqi App will continue to explore serverless architecture based on its own technical characteristics. While embracing new technologies, it will also be able to fully enjoy the benefits of cloud computing.
Copyright Statement: content of this article is contributed spontaneously 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) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。