Aliyun account recharge channel: how does Aliyun ECS perfectly carry live broadcast and on-demand?
In today's era of "national live broadcast" and "short video flying all over the sky", whether it is doing cross-border e-commerce live broadcast, enterprise online training, or building a vertical video-on-demand website, audio and video business is the scene that burns the most money and tests the technical architecture most.
Many friends or entrepreneurs who have just come into contact with audio and video development often fall into a misunderstanding: "Do you want to engage in live video broadcasting? Then I will go to Aliyun to buy some high-quality ECS (cloud server), how much bandwidth can be pulled, so that users can directly connect to the server to watch videos?"
Listen to my advice, if you really do this, the day the project goes online will be your bankruptcy day.
The high concurrency and high traffic characteristics of audio and video services determine that it must not rely on single server hard resistance. A mature architecture that can perfectly host live and on-demand must be based on
Large bandwidth ECS as the core brain, with high concurrency push flow optimization, and then accelerated by CDN weaving into network wings
The "Trinity" combination punch.
In today's article, let's not talk about complicated audio and video coding algorithms, but directly use the vernacular real-life writing style to teach you how to use Aliyun ECS to play live broadcast and on-demand, so as to cut down the cost and improve the smoothness.
The first stage: role dismantling-what do these troika do respectively?
If you want a stable structure, you have to do your job first. We need to separate the service links between live broadcast and on-demand, and let different Alibaba Cloud products do what they do best:
Alibaba Cloud account recharge channel
Large bandwidth ECS (core brain): It is not responsible for sending video data to thousands of viewers, it is only responsible for "core logic" and "media processing". For example, user login authentication, pop-up management, gift system, upload of on-demand video, and "transcoding work" of transcoding original large video slices into high definition/standard definition ".
High concurrency push stream (water inlet): whether the anchor broadcasts live on the mobile phone or uploads the recorded video source, this belongs to the "input" of data ". We need to configure efficient streaming media protocols (such as RTMP and SRT) on ECS or Alibaba Cloud Video Cloud (Live/VOD) to ensure that the source signal advances quickly and steadily.
CDN acceleration (water outlet): This is the key to decide whether the audience card is not. 99% of the audience traffic must be carried by CDN (content delivery network). CDN caches video content distribution on ECS to thousands of edge nodes across the country and even around the world. When viewers watch videos, they directly fetch data nearby without connecting to your source ECS at all.
The second stage: practical landing-live (Live) architecture how to perfect configuration?
The live broadcast is characterized by "extremely strong timeliness and high concurrency burst". For example, at 8 pm, the broadcast was launched and 50000 people poured in instantly.
1. Architecture construction: ECS acts as streaming media server
You can set up a computing type (such as ECS c8i series) cloud server in Aliyun.
Why choose the computing type: because the live stream is in progress
After entering the server, it is often necessary to carry out "real-time transcoding" (for example, the 4K code rate pushed by the anchor is cut out in real time to 1080P and 720P for viewers in different network situations to choose from), which consumes extremely CPU computing power.
Software configuration: Deploy a self-built streaming media system (such as SRS and NGINX-RTMP) on ECS or directly connect to Alibaba Cloud's live video service (Live).
2. High concurrency push flow optimization
The segment from the host terminal (stream push terminal) to the ECS source station must be "absolutely stable and cannot be dropped".
Protocol selection: RTMP is used in traditional push streaming. Although it is mature, it is easy to be stuck in a transnational or weak network environment. It is recommended to enable the SRT protocol or the RTS (Ultra Low Latency Live Broadcast) protocol of Aliyun on ECS. The SRT protocol can still ensure that the picture will not be displayed or interrupted under a bad network with a packet loss rate of 20%.
Network configuration: The public network bandwidth of the origin ECS does not need to be unlimited, but the intranet throughput and network packet sending and receiving capacity (PPS) must be high. Because pushing and slicing all depend on it.
3. Cooperate with CDN to realize ten thousand people to see together
If 10000 people directly connect to your ECS to watch the live broadcast, according to the code rate of 2M per person, 20Gbps of bandwidth is required, and the network card of a single server will burn instantly.
Life-saving operation: Activate CDN acceleration for live video streaming in the Alibaba Cloud console. Associate your live push basin name with the broadcast domain name.
Traffic trend: anchor pushes to ECS -> ECS completes real-time transcoding-> CDN directly goes to ECS to pull a single transcoded stream (back to source) -> CDN copies and distributes the whole stream to the global edge node-> 10000 viewers connect to the CDN node nearby.
Results: Your ECS only needs to bear 1 back-to-source bandwidth (several megabytes), and the remaining 20G pressure is easily resolved by CDN nodes.
The third stage: practical landing-on-demand (VOD) architecture how to perfect configuration?
VOD (watching recorded videos, online classes, and short videos) is characterized by "high concurrent disk reading, huge traffic, but no live broadcast emphasizes absolute zero delay".
1. Separation of storage and transcoding: ECS + OSS golden partner
Alibaba Cloud account top-up channels
Many novices directly put hundreds of GB of video in ECS cloud disk for users to download. This will cause the ECS hard disk I/O (read/write speed) to run full instantly, the entire server stuck.
Correct approach: Never store video files on ECS hard disk, and store them all in Aliyun OSS (Object Storage). OSS is cheap, has large wireless space, and naturally supports ultra-high concurrent reading.
ECS role: only runs transcoding scripts (such as FFmpeg) in the background. When the administrator uploads a 1G original MP4 video, ECS automatically starts a background process and slices it
Countless small. ts files of a few seconds, and generate a. m3u8 index file (HLS protocol format), and then throw these slices into OSS.
2. CDN Acceleration: Let Video Open in Seconds
Since video on demand is a static file (once recorded, it will not change), it is the most perfect acceleration object for CDN.
Configure CDN caching service: in the Alibaba Cloud CDN background, point your video playback domain name to OSS or ECS.
Anti-brush and anti-theft chain (big pit warning): on-demand is most afraid of being "stolen brush traffic" or "stolen broadcast" by others ". If your video is hung by a malicious website, a CDN traffic fee of several hundred t overnight can make you bankrupt.
Security configuration: URL authentication (A/B/C mode), Referer anti-theft chain, and IP black and white lists must be enabled in the CDN console. CDN will only release the playback after passing the encrypted link with the time-sensitive Token calculated by your ECS backend.
The fourth stage: fine cost to the ledger (R & D and the boss must see)
Audio and video services are "traffic devourers". How can you save the most money on Alibaba Cloud? Here are two industry secrets:
CDN billing mode switch: If your live broadcast or on-demand service has low traffic at ordinary times, but suddenly increases in a specific period of time (such as evenings and weekends), do not select fixed bandwidth for billing mode. Please select "Billing by Traffic" or "High Anti-Dends Monthly 95 Bandwidth Billing" for major customers ".
Purchase of resource packages: whether it is CDN traffic or OSS storage, buying "downlink traffic packages" directly on ariyun activity page is at least 30% to 50% cheaper than directly deducting the cash balance of your account.
Summary
Using Aliyun ECS to perfectly carry live broadcast and on-demand is essentially an architectural art of "light front and heavy back.
Leave ECS in the rear so that it can use high-frequency CPU to run high and concurrent streaming, transcoding and complex business logic. OSS is regarded as the most solid ammunition depot to store massive videos. Finally, CDN was pushed to the front as a solid shield and highway to meet the traffic impact of tens of millions of users. Understand this "trinity" linkage configuration, your audio and video business can not only do not stop in seconds, but also help the company save a lot of money, in the sea or domestic video track stable burst single.
Alibaba Cloud account top-up channels
