Golang's high-performance practice on the live video platform (including PPT download)
Editor's note: This article is compiled based on Yang Wuming's speech at the Gopher Beijing gathering on February 27. Please indicate that it is from the high-availability architecture public account "ArchNotes".
Yang Wuming, Chief Architect of Panda TV, formerly head of Qihoo 360 PC online game technology architecture, and former senior back-end development and technical expert on Sina Weibo platform. He has rich practical experience in large-scale Internet architecture, and is good at back-end basic service and component development, especially high-performance, high-concurrency, and big-data business scenarios.
Panda TV is a live video platform. Let’s first introduce the environment in which our system runs. The following 6 major services are only part of our dozens of services. Due to the high concurrency and importance, they have become the first batch of golang trials. High-performance and high-concurrency services.
Breaking down large services and then deploying them as independent services makes it easier to simplify deployment and to optimize and upgrade a single point of detail. The capabilities of most services are universal, such as smooth restart, multi-computer room deployment, etc.
Regarding online services, if 10 million users are online, even if online http sends RBI once every 30 seconds, there will be 300,000+ interface qps per second.
The http server provided by Golang has very good performance. If an ordinary engineer can support 1w-2w requests per second on a single virtual machine, then only 10-20 background servers are needed.
With other non-high-performance languages, the required machine capacity needs to be doubled several times; C++ has sufficient performance, but requires high engineers.
Room service is the main service and requires core protection, so the sections in the room service have been divided into more granular details.
Separate storage is also used for content with frequent changes in room information, such as the number of people count and other fields. The disadvantage of this is that every time the room information is visited, it will bring an extra visitor service cost. This is also one of the trade-offs in architecture design.
The gift system is the standard configuration of most live video platforms. There are many local tyrants with gift consumption habits in China, and there is a large amount of concurrency to give gifts during peak periods, especially when many local tyrants collude.
The gift system has slightly higher requirements for consistency, so storing one piece of data and building multiple indexes is also an option, which can also reduce the dependence on transactions.
The barrage interaction method is a very good experience, more youthful, and a large number of users like to interact with the anchor in this way.
The domestic network situation is more complicated. It is best to select the nearest single-line computer room of the corresponding operator to access the barrage message service according to the user's location to make the barrage more timely. You can also use a BGP computer room, but the network bandwidth price will be much more expensive than a single line.
For large rooms, the volume of barrage messages is so large that both anchors and users cannot come over. Some experience optimization can be done at the product strategy level.
The live video experience is the most critical point of the overall platform. Video CDN is a technology that allows users to obtain the required streaming media nearby and solves problems such as delay and freeze. From a technical point of view, don’t just rely on a certain CDN provider or line. Many live video platforms in the industry have made mutual backup of streaming lines. After streaming, video (transcoding, forwarding) clustering is also an optimization point. Some push streaming resources are redundant, but the experience and high availability of optimizing live streaming are obvious.
The interface proxy service that contains free business logic is a public service that many companies have. It can provide the company's intranet service to the external network at a low cost. However, external network security strategies need to be considered, including authorization and authentication, service relationship mapping, frequency restriction, and business resource isolation.
I can see that it is definitely friends who are interested in our technology and business. The Panda TV technical team is recruiting Golang engineers, all equipped with high-end computers and DELL dual-screen large-screen displays, and providing a challenging technical environment. Interested friends, please scan the code to enter (at the same time there are a large number of PHP, front-end, operation and maintenance, DBA and other technical positions).
The above is the main content of this sharing, click to read the original text to download the PPT.
Learn more about Yang Wuming: From a monthly salary of 3,000 yuan to a programmer to chief architect
To reprint this article, please indicate that it is from the high-availability framework "ArchNotes" WeChat official account and include the following QR code.