I saw the tiger sniff push “Wang Sicong sa coin” news on January 4, and then began to examine the technology behind. It involves live streaming, real-time bullet screen, OAuth2.0 open authorization, SMS API, Push gateway, payment interface and other services, and its technical implementation is not complex, which we analyze.

UI design

It can be said that the summit conference is to copy the business logic, business logic and UI design of HQ. Presumably in the short term there will be more knowledge quiz APP swarms. I won’t comment too much on that, just the technology behind it, not the business.

Flutter

I’m a google-dumb fan. It’s rumored that Google’s Fuchsia OS UI was designed with Flutter. Here, the Android and IOS ADAPTS are implemented using Flutter. The specific design can be completely modeled after HQ.

The business logic

The technical difficulties of topping up big-conference apps are high concurrency and timeliness. To this end, we need to decouplet the business and separate registration/login, live broadcast, bullet screen, Q&A, award pool, push and sharing, which will help business expansion and ensure high concurrency and follow-up maintenance problems.

Among them, the main business difficulties and focus on live broadcast, bullet screen, q&A. Live streaming and bullet screens are the main traffic outlets, and separating them helps to ensure high concurrency and timeliness.

live

Companies can set up their own live-streaming services or purchase cloud services. Let’s say we use Alibaba’s live video service. In the live broadcast, the video stream is encoded, transmitted, transcoded, accelerated and pushed to the client.

barrage

The bullet screen can be made into a simple request form or a message queue. Of course, message queues can also be selected from cloud services, but here we use Kafka, deployed on a cluster of servers for load balancing. For users with low network speed, we can disable the bullet screen function by default to enhance user experience. We’ll talk more about high concurrency and timeliness later.

Question and answer

As the most relevant business logic for the user, we want to ensure that the user receives the message “in seconds”. Here we can apply a trick called “push synchronously, feedback asynchronously”. That is to say, after the moderator gives the question, the question is pushed by a single server. However, considering the different delays of users’ network conditions, we can receive the answer results of users asynchronously, and the maximum time of asynchronous feedback can be designed as 10s and 15s.

Other business

Registration/login: call wechat OAuth 2.0 open authorization. Refer to the wechat open platform interface document for details, which will not be described here. Prize pool: unified distribution at the end of the q&A session, simple business, not to repeat. Call alipay withdrawal interface. Push: You can use push gateways, you can use HTTP polling, you can use cloud services. Share: call each platform to share the interface.

High load

I suggest that the load balancing server is assumed in Beijing, Shanghai and Hong Kong, with Beijing serving northern users, Shanghai serving southern users, and Hong Kong serving Hong Kong, Macao, Taiwan and overseas users. Hadoop, ZooKeeper, Docker, Nginx and so on are used technically.

The DNS is used to resolve user IP addresses in different geographical locations to automatically distribute and adapt traffic. We set up the subregion display of bullet screen according to different geographical locations of users. Use CDN acceleration.

operating

It can be said that every live broadcast is an operation, because there is a “host” factor, so the answer push and answer results need to be “manual” control. The operation is to prepare the topic before the live broadcast and enter the topic into a database, or a configuration script. In the process of moderator interaction, real-time questions will be pushed and the answer results will be fed back to the moderator.

The last

We exclude labor costs and bonus costs and calculate technical costs separately. A single q&A live broadcast is about 20 minutes, and we conduct trial calculation every day with a peak flow of 10G. The technical cost is about 10,000 yuan per day. Of course, this is after the number of users reached a certain scale. In the Internet industry, that’s not high. Therefore, in a short period of time, there will be a large number of knowledge quiz APP.

This article only looks at the technical implementation as a whole and does not go into too much detail. But for some experienced companies, especially livestreaming companies, I think it won’t take more than a week to make this APP. We’ll see.

This article is welcome to reprint, but wechat reprint please contact the public account: Caiyongji for authorized reprint.