当前位置:网站首页>Application architecture of large live broadcast platform
Application architecture of large live broadcast platform
2022-07-06 13:15:00 【Wang Qingpei】
It's been a while since we entered the live broadcast field .
Like most of you , New to the field of live broadcasting, people are very curious about the macro structure of this field .
Here I study according to my time , To sum up, share it with interested partners to sweep literacy .
At present, there are many live broadcast platforms , Shaking, / fast 、B standing 、 Bucket / Tiger, etc .
The efficient interaction mode of live broadcasting is the ability that all industries need to have , With the development of network technology, it is also an inevitable trend .
Put aside the different content of each live broadcast , A complete live broadcast platform needs to include at least the following core functions .
Watch the live broadcast 、 Send the barrage 、 Reward and give gifts 、 Anchor interaction .
We take an ordinary C End user perspective , Take a look at the general application architecture behind these core functions .
Watch the live broadcast
When we enter the live broadcast room, we first watch the live broadcast content .
【 Pull flow 】
The live broadcast content is through Streaming media player Play out , And streaming media player through Stream Address To pull Stream data , Reprocess related decode Work , Finally, the picture and sound are presented .
In order to ensure that users all over the country and even overseas can watch the live broadcast smoothly , You need strong physical network coverage .
Streaming media data passes upstream CDN Origin push ( Or push-pull combination ) To all edge nodes .
Users in different regions through overall situation CDN-DNS After scheduling , Visit nearby CDN node .
In order to cover all areas as much as possible , It is impossible for every company to build a huge network infrastructure .
At this time, we need to rely on a powerful public cloud platform (BAT、 Huawei 、 jinshan 、 Bytes, etc ).
Public cloud manufacturers spent a huge amount of money on building physical links , As an application-oriented enterprise, you only need to use cloud product capabilities , Everything is service .
When we watched the live broadcast happily , You will be curious about the source of these live content , How are these pictures collected , How to transmit data .
【 Push flow 】
Usually there is a broadcasting tool for broadcasting , The launch tool is specially used to collect streaming media ( Audio and video equipment ) Information and media stream synthesis , It can also be used. OBS And other powerful streaming tools .
When the broadcasting tool collects media information, it will conduct local compression , And then through RTMP(Real Time Message Protocol) The protocol pushes data to RTMP The server .
RTMP After the server receives the streaming media data , The stream information will be decoded and HLS(HTTP Live Streaming) File slice .
take RTMP The server is deployed on the public virtual machine , It is to use the internal services of the public cloud (LAAS、PAAS) The affinity of , It can maximize the convenient coverage to CDN Edge node .
You may be curious , Why is streaming used RTMP Agreement and pull flow HLS agreement .
The broadcast end uses RTMP, Because RTMP be based on TCP Real time protocol , It can ensure the reliability and real-time of streaming .
See end use HLS Because HLS It is based on static small files , This is more convenient in large-scale millions PCU(Peak concurrent users ) when , Use static CDN Easy to distribute advantage to cover .
Use HLS At the same time, it is also convenient for dynamic switching between different code rates , So as to select the best viewing experience according to the user's network situation .
such as , Users are under weak network , We'll switch to low bit rate to watch .
When the user network is good , We'll switch to high bit rate to watch , At the same time, you can also use some advanced viewing experience and interaction .
Of course ,HLS There are many advantages , In compression 、 Encryption and decryption are very mature .
stay 2C Large scale live broadcast ,flv It's the past tense ,HLS Is the future .
【P2P】
In order to save as much as possible CDN The huge cost , Will use P2P(Peer to Peer) Technology to reduce public cloud bandwidth usage .
Again , In order to make STUN The server 、 Signaling server Closer to the user , Both servers are deployed on public cloud edge hosts .
Further crushing costs , You can also use PCDN(P2PCDN) service .
Due to the strong terminal network coverage of the public cloud ( Router 、 Terminal equipment, etc ) Can be CDN Distribution content is further marginalized .
Use tens of thousands of edge computing capabilities to extend content and computing to the end of users .
Actually P2P The technology is already very mature and has a better history than WEB The Internet has a long history .
Send the barrage
When watching the live broadcast, a very important appeal is to interact with the anchor , And the barrage is the interactive way with the largest amount of information .
bullet chat It is now an indispensable media element in the video field .
The barrage was originally in the field of on-demand , Japan's Niconico It can be regarded as the ancestor of barrage interaction .
A standing (Acfun) It is basically the cultural birthplace of domestic bullet screen video websites .
But at present, those who play the bullet screen into a new dimension in China are B standing (bilibili) 了 .
Barrage from send to receive , rely on A long connection middleware .
Considering the platform availability , Long connection services as a whole need to support disaster recovery , The whole architecture needs to support the mixed deployment of multiple machine rooms .
At the bullet screen message delivery end, it is necessary to do computer room line detection , Select the best computer room according to the relevant data after exploration .
There is another advantage of using public cloud , You can enjoy a certain amount “ Peer to peer connection ” Value added service .
The overall architecture is increasingly moving towards hybrid clouds , It is to balance the core data closed loop of private cloud as much as possible , At the same time, with the powerful network coverage of the public cloud .
Public cloud high-performance hosts can generally carry millions of connections at low frequencies , The bottleneck basically lies in memory and bandwidth .
The cost of the machine is actually good , Because machines can theoretically expand infinitely , But the bandwidth has a physical upper limit , So it's more expensive .
【 Public opinion control 】
Any Internet company with a certain volume , According to the industry and content , We need to control the public opinion of users' participation behavior .
The barrage area is a major position that needs to be controlled , It is also one of the core battlefields in charge of each security center .
The characteristics of the barrage are precisely difficult to control , Usually the idea is based on AI Algorithm ( Such as NLP) Filter the content of the barrage with pre sensitive words 、 Emotional analysis, negative filtering, etc .
Actually ,AI What the algorithm can deal with is relatively simple and easy to recognize semantics .
Chinese characters and culture are broad and profound , Plus complicated words 、 Words stem together , Even the most powerful algorithm cannot absolutely recognize .
Manual auxiliary approval is required , Labor also needs a certain “ Culture ” Profound and quite extensive “ width of knowledge ”.
So it must be a very large audit team .
General application enterprises , The technical content of making barrage function is not high , And now cloud vendors 、 Open source sdk, With a little combination, the architecture can basically be built .
Instead, it's , Security 、 Public opinion control is the most critical and key investment .
Now, more and more companies are doing third-party public opinion discovery and control , There are still many social public opinion control companies , Subdivided vertical classes are relatively few .
Give gifts and rewards
After watching a hard-working performance by the anchor , You need to express your sincerity by rewarding .
A seemingly simple gift , In fact, there are many systems involved , These systems are located at different levels of responsibility .
But whether in the field of live broadcasting or e-commerce 、 education , It's basically similar , Just selling different goods .
On the gift chain , Order 、 Account 、 Clearing and settlement is actually a relatively mature transaction 、 Financial model .
These two pieces are basically set according to the pattern , The purpose is to complete the company's revenue recognition and capital settlement .
【 The whole link 】
We divide the whole link into two layers , The first level is the sales business level , This floor consists of a series of sales units , Like the mall 、 Promotion Center, etc .
In the field of live broadcasting , The gift giving system is located on this floor , Gift giving can be considered as a virtual commodity transaction .
Gift giving scenes can be very diverse , But they are all in disguise to promote the conclusion of the transaction .
Once the goods are sold successfully , According to the nature of business , The amount and time point of revenue recognition are also different .
In live gift giving , The gift given is basically to confirm the income in near real time , At this point, you need to trade orders ( Or business order ) To carry this part of the transaction responsibility .
At the lower level of the sales business layer is the transaction settlement layer , It is the division of income 、 Settlement 、 Payment part .
The core of this part is the transaction supporting the business sale , Settle the income of each role . It is the most complex part of the transaction settlement system , It is also prone to asset losses .
No matter what we sell , To run completely in the trading system , First of all, we need to commercialize the concept of virtual sales .
After having goods, you can sell them on the shelves through the sales layer .
The business of gift giving is relatively simple , Deduct the virtual assets of personal account , Add it to the anchor account , It completes the basic business process .
When this is done , Then you need to separate the transaction order . Separate computing platforms are required 、 External merchants / How much do participants in various roles such as institutions get .
After a successful gift giving, at least a platform is needed 、 The host ( Or labor union ) Make a certain share .
This part is the responsibility of the clearing part of the clearing and settlement system , This part is charged 、 Allocate and calculate the settlement details of each role separately .
The settlement system will retrieve the settlement cycle of the contract on a regular basis (T+N/ Monthly settlement, etc ) Settle accounts and make payments to merchants , Most of this part has an accounting period .
in short , Gifts and rewards are biased towards the field of transaction settlement , The core of the whole system is accounting 、 transaction 、 Financial and other business knowledge .
At the same time, in the system design , Data consistency 、 Reconciliation process and scenario are the core of the whole system architecture design .
Anchor interaction
In the studio , Whether for the anchor or the platform , Are the ultimate goal . But this ultimate goal cannot be achieved in one step , It needs to be constantly transformed through other scenes .
Most of the needs of live broadcast users are hormone needs , How to use various interactive tools 、 Form of interaction , Let users and anchors interact with each other more , To promote gift giving .
From the perspective of users, the forms of interaction are mainly divided into three categories , bullet chat 、 gesture 、 Gift giving .
Such as shaking / Double click the screen to like , Long press of tiger teeth to recall the shortcut panel ,B Station sending special barrage trigger “ Thermal storm ” Special effects, etc .
At the same time, almost every family has special gift interaction , Change the theme of the room by giving special gifts 、 The change of the anchor's dress .
All forms of interaction need unified abstract management , It can be summed up in one sentence : “ In the specified room for the specified period of time , Enable one or more interactive activities / How to play ”.
As for a specific interactive play , What materials are needed for this game , What trigger media are needed , In addition to the channel part, you can subscribe , Others need customized development .
such as , Energy storage in the interaction between bullets and curtains , In addition to the general barrage channel , Which words , How many times in how many time windows , Then trigger what business logic .
Or combo gift storage , In addition to the gift giving channel is a general part , What gifts , How many time windows to send , How much money is satisfied is where the business logic needs to capture and process .
The whole interaction needs to get through the viewing end and the broadcasting end .
There is a clear difference between watching end effects and broadcasting end effects , Most of the viewing terminals are special effects elements that can interact in the live studio , And the special effects on the broadcasting end are finally reflected in the stream .
such as , An interactive special effect for gift giving , user “ continuity ” When the gift reaches a certain threshold, it triggers the interactive logic of the broadcaster , Finally, input the message into the stream , At the same time, see whether the requirements are added SEI(Supplemental Enhancement Information) Information .
Room theme
If we compare the live studio to a real room , We hope it's a thousand people and a thousand faces , And it has certain customization .
meanwhile , We hope the room can automatically sense the holiday according to the calendar for entertainment 、 Seriousness .
If we compare the live studio to an online community unit , This place is not beyond the law , Need to be affected by different degrees of public opinion 、 Social sensitivity 、 Legal safety supervision .
The live broadcasting room is divided according to the business form , There are many dimensions to divide , For example, commercial rooms ( Take the goods / Online retailers / distribution )、 Game room 、K Song room 、 Projection hall, etc .
Final , Different rooms need to be opened 、 Control some capabilities , Interactive entertainment , Gift giving , Anchor behavior, etc .
Calendar and theme management are the basic genes of the whole room generation .
It is necessary to carry out engineering design for the whole structure of the room , Be interface oriented 、 Open standards oriented .
Only in this way can it be customized and extensible .
The whole room probably has several core areas , ___ Gift area 、 Player area 、 The barrage area 、 Interactive area .
The implementation of these areas needs to be divided into two layers , The first layer realizes the core basic functions of the kernel .
This part of the function can directly exclude topic relevance .
The second layer is other decorative functions , The implementation of this part requires theme awareness .
On top of that , We assume to realize a special barrage effect in the barrage area .
The implementation plug-in passes the engineering interface and standard , Get the calendar & The theme can perceive the attributes of the festival . In terms of implementation, basic functions and effect functions can be separated .
This design is also convenient for automatic testing and business inspection of effect functions on special festivals throughout the year .
The room recommendation algorithm needs to add a calendar recommendation factor , This part is easy to understand . What is more interesting is that the center of the room structure is the outlet of the finished room .
Activity guarantee
Finally, share the content of technical support .
This part is a concise summary , Do not describe the process .
in short , Guarantee mainly focuses on two key points .
The first point is that most of our familiar application systems are generally resistant to high concurrency , This includes a series of middleware 、DB、 cache 、 Microservice suite, etc .
The second point is to follow PCU Related linear resources CDN bandwidth 、P2P bandwidth 、 Long connection bandwidth 、 Dot 、 Real time report calculation .
According to the view 、 Look at the two ends of the broadcast separately .
Broadcast end , We need to focus on ensuring the availability of streaming , So basically, there are at least two streams on the push side backup.
Look at the end ,QPS、TPS The relevant interface is basically related to slope or sudden increase of flow .
( notes : The peak value of an interface can be carried 10wQPS, Reaching this peak is minutes per second plus 1w Slowly increase , still 1s arrive 10w It's different .)
The essence of the slope is to test the capacity expansion speed of related resources at the back end .
In a large concurrency scenario , Sometimes we need to expand capacity in advance to prevent sudden increase of traffic .
This is also the difficulty of evaluating expansion resources according to the slope .
On the other hand, it is with PCU Linearly related .
PCU The direct result is related public cloud bandwidth 、 The proportion of connection pool increases , This part needs to do a good job of resource pre purchase .
When the number of people online is very high , Data reporting 、 Real time data processing also increases linearly .
This part of storage resources needs to be prepared in advance , Computing resources can be flexibly scheduled .
All the above scenarios can be carried by the system within a reasonable capacity , But once unexpected traffic comes in, we also need to have a self-protection mechanism and switching capacity .
This part is related , Current limiting 、 Degradation capability is also essential .
边栏推荐
- Employment of cashier [differential constraint]
- RTKLIB: demo5 b34f. 1 vs b33
- String class
- TYUT太原理工大学2022软工导论考试题型大纲
- Several high-frequency JVM interview questions
- [algorithm] sword finger offer2 golang interview question 13: sum of numbers of two-dimensional submatrix
- MySQL 三万字精华总结 + 面试100 问,吊打面试官绰绰有余(收藏系列
- 记录:Navicat Premium初次无法连接数据库MySQL之解决
- Decomposition relation model of the 2022 database of tyut Taiyuan University of Technology
- Sharing ideas of on-chip transplantation based on rtklib source code
猜你喜欢
[算法] 剑指offer2 golang 面试题3:前n个数字二进制形式中1的个数
2-year experience summary, tell you how to do a good job in project management
Answer to "software testing" exercise: Chapter 1
TYUT太原理工大学2022数据库大题之分解关系模式
十分钟彻底掌握缓存击穿、缓存穿透、缓存雪崩
Iterable、Collection、List 的常见方法签名以及含义
[algorithm] sword finger offer2 golang interview question 6: sum of two numbers in the sorting array
Basic DOS commands
阿里云微服务(二) 分布式服务配置中心以及Nacos的使用场景及实现介绍
面试必备:聊聊分布式锁的多种实现!
随机推荐
121 distributed interview questions and answers
IText 7 generate PDF summary
Usage differences between isempty and isblank
Small exercise of library management system
System design learning (I) design pastebin com (or Bit.ly)
The port is occupied because the service is not shut down normally
Record: I accidentally wrote a recursion next time
2-year experience summary, tell you how to do a good job in project management
Realization of the code for calculating the mean square error of GPS Height Fitting
分支语句和循环语句
[算法] 剑指offer2 golang 面试题3:前n个数字二进制形式中1的个数
Edit distance (multi-source BFS)
【快趁你舍友打游戏,来看道题吧】
系统设计学习(二)Design a key-value cache to save the results of the most recent web server queries
Alibaba cloud microservices (I) service registry Nacos, rest template and feign client
TYUT太原理工大学2022软工导论简答题
Rt-ppp test using rtknavi
[algorithm] sword finger offer2 golang interview question 13: sum of numbers of two-dimensional submatrix
MySQL backup -- common errors in xtrabackup backup
面渣逆袭:Redis连环五十二问,三万字+八十图详解。