Did you draw a lottery? Count the technical support behind the red envelopes for the Spring Festival

This article is reproduced from InfoQ

In addition to watching the Spring Festival Gala on New Year's Eve, participating in the Spring Festival red envelope activities of major apps has gradually become a Chinese New Year tradition. Red envelopes are no longer just "money", but take on more roles and become the traffic entrance and growth engine of the application. The realization of the Spring Festival red envelope is indispensable with the support of new technologies such as big data, cloud computing, and payment and settlement. This article collects the technical practices of the Spring Festival red envelopes publicly shared by four major companies, Alipay, WeChat, Kuaishou, and QQ, for readers.

1 Have you been blessed? Realization of Alipay Red Packet

"Professional dedication, did you get it?" I believe you should have heard this sentence frequently these days. Alipay set Wufu has become a must-have interaction for most people during the Spring Festival. More than 300 million people gathered for the Spring Festival in 2020, and this year's Jifu activity has new tricks, in addition to the traditional AR sweeping blessing and Ant Forest. Added the word "Fu" and Baba Farm.

Among them, the Sweeping Fortune Card may have the largest number of participants. In order to solve the problem of high concurrency, the architecture system of client + server parallel processing is adopted, which can support two recognition methods: all pictures are transmitted to the server for processing. Processing, the recognition accuracy is higher, but the number that the server can handle is limited; the second is to go through the client detection first, and upload the server if the client cannot recognize it. The client's detection capability is slightly weaker, but distributing the computing power to each terminal can greatly alleviate the pressure on the server.

What is the technical support behind the five blessing activities that so many people have participated in? The Alipay team once shared their technical guarantees. In terms of data, the two databases are GeaBase and OceanBase.

Since there are many user interaction scenarios in the Wufu event, taking the Friends Fuca Ranking list as an example, although it seems that it only counts the total number of Fuca for each friend and then sorts them, when the user level rises, the difficulty of this matter becomes increased. Assuming that each person has ten friends and the number of users participating in the activity is 100 million, then the magnitude of the query will reach billions, and the number of Fukas needs to be updated in real time.

In this case, the performance of ordinary relational databases such as Oracle and MySQL is not particularly outstanding. Inquiry of users' friends can be completed within milliseconds, while inquiring about friends of friends will increase exponentially. The deeper the query, the more time-consuming The longer. Therefore, the distributed graph database GeaBase independently developed by Ant Financial is used in the application scenario of Jiwufu.

Due to the difference in data storage structure and query rules, the query depth has almost no significant impact on the speed of Geabase. Relational databases take 30 seconds to obtain query results, while GeaBase only takes 0.168 seconds. Relational databases are difficult to provide results for queries, and Geabase also It only takes 2 seconds to complete.

In national activities such as Jiwufu, the peak traffic is a big test for the server's pressure-bearing capacity. At the moment when the lottery is drawn, it is the moment when the answer sheet is handed in and the results are issued. There are dozens of data behind the winning logic of each user, and there are billions of data that need to be synchronized as a whole. These data need to be synchronized within 2 minutes, and the number of concurrent data is as high as tens of millions per second.

How to allocate server resources more efficiently and cost-effectively? OceanBase has played a role in this. It can schedule resources to take over traffic within minutes, and it can also quickly recover resources after the flood peak has passed to avoid waste.

2 Did you grab the red envelope? Realization of WeChat Red Packet

During the Chinese New Year, grabbing red envelopes in various WeChat groups has become a popular way to celebrate the Spring Festival. The relatively new change of WeChat red envelopes this year is that you can make your own personalized red envelope covers.

I believe everyone is familiar with the steps to use WeChat red envelopes, including package, sending, grabbing, dismantling, querying the number of red envelopes sent and receiving red envelopes. Among them, the key is to send red envelopes and grab red envelopes. This is the perspective of our ordinary users. From the perspective of the WeChat team, the red envelope system consists of three parts: information flow, business flow and capital flow. These three parts are completed by different back-end teams in the organizational structure: information flow-WeChat back-end, business flow-WeChat payment back-end, and capital flow-Tenpay back-end.

imageRed envelope system architecture during the 2016 New Year's Eve event

How to be both lightweight and reliable during the red envelope grabbing phase? According to the introduction of the WeChat team, there are mainly three ways:

  • Zero RPC call: In general, the request initiated by the client is forwarded to the specific business service for processing through the access service, and an RPC call is generated. However, the Shake logic is directly embedded in the access service, and the access service can directly process Shake requests and distribute red envelopes.

  • Zero database storage: In the process of grabbing red envelopes, the WeChat team does not use a database at all, and can achieve several orders of magnitude performance improvement, while reliability is better guaranteed.

  • Asynchronization: After the user grabs the red envelope, the subsequent accounting processing will not be performed synchronously. The request will be placed in the red envelope asynchronous queue, and then transferred to the WeChat payment background through the asynchronous queue, and the WeChat payment background will complete the subsequent business logic.

At the same time, in order to deal with the problem of network fragmentation, the WeChat team has built three independent data parks in each data center, so that failures such as network splitting can occur in any data park, and even after it has completely become an island in the park, the other two The data park can accept requests from the entire data center without any damage.

3 Did you throw the dice? Realization of Kuaishou Red Envelope

On February 5, 2021, Kuaishou was listed in Hong Kong. It opened up 194% to 338 Hong Kong dollars per share, with an issue price of 115 Hong Kong dollars per share, and its total market value was as high as 1.39 trillion Hong Kong dollars. This year, Kuaishou planned a 2.1 billion bullish accumulation activity, including games such as throwing dice, gathering luck, and fighting bullishness.

In 2020, Kuaishou became the exclusive interactive partner of CCTV Spring Festival Gala. In the “Spring Festival 1 billion cash red envelopes” event, the total number of Kuaishou red envelope interactions reached 63.9 billion times, and the number of red envelopes shared outside the station reached 590 million times. The Kuaishou Spring Festival Gala live broadcast room has a total of 780 million viewers, and the highest number of concurrent users is 25.24 million.

Kuaishou played a lot of new tricks on the basis of the traditional red envelopes, and added a lot of new year special effects, such as New Year's lights, landmark AR, cute baby New Year's greetings, my life and so on.

The realization of these special effects applies technologies such as MR and AR. MR is a mixed reality technology that integrates Spring Festival elements with the real world to create an environment where virtual and physical objects coexist and can interact in real time, bringing an immersive user experience. The MR algorithm of Kuaishou App uses a single camera to collect image data, uses deep learning and stereo geometry algorithms to estimate the position of the camera, and then outputs 3D data in real time, successfully fusing the MR effect into the real world.

In addition to these technologies that everyone can feel, there are also some technical practices that silently support the entire red envelope. Chen Hongliang, a senior engineer at Tencent Cloud, previously shared how Tencent Cloud File Storage CFS supports fast-hand app advertising recommendations.

It is understood that CFS file storage is mainly paired with TKE container nodes to provide guarantee for Kuaishou's advertising recommendation business during the Spring Festival. CFS mainly participates in three specific advertising recommendation business processes, namely model file release, business application acquisition model, and advertising recommendation. During the Spring Festival, Kuaishou used 3 TKE container clusters on Tencent Cloud with a total of 4000+ Nodes and more than 8000 Pods to share business pressure. These Pods need to load a set of model files ranging from tens of GB (the combination has several sets in total) before the application can be started.

4 Have you brushed it? Realization of QQ Spring Festival Red Envelope

Like the red envelopes on other platforms, the QQ Spring Festival red envelopes also have many forms, such as corporate red envelopes, swipe red envelopes, and AR red envelopes.

It is reported that the QQ Spring Festival red envelope project involves many business systems such as mobile QQ mobile terminal, mobile QQQ backend, QQ wallet (tenpay) system, gift certificate system, official account, etc. The process is long and numerous, and the performance throughput of each system varies greatly. The QQ team once shared the technical practices behind QQ's 2017 Spring Festival red envelopes.

The simplified structure of the QQ red envelope is mainly composed of the following parts: access layer, lottery system, storage system, delivery system, official account message notification and CDN resources. Among them, the access layer is the gate of the red envelope back-end service, which is responsible for the pre-processing of lottery requests to ensure that valid requests are transparently transmitted to the back-end services; the lottery system is the core system of QQ red envelopes, which is responsible for accepting user lottery requests, with a reasonable probability of design Complete the lottery operation, and save the lottery results safely; the delivery system is mainly to ensure that the final gift is delivered to the user's account, QQ wallet balance, QQ card coupon or third-party system account.

The main characteristics of the Spring Festival red envelopes are massive and instant kill. What users expect is to grab them smoothly after seeing the red envelopes. Therefore, reducing latency and eliminating stuttering is the most direct experience. Even in a weak network environment, it can be as smooth as silk. slip. Based on this, the QQ team has made many optimizations in technology.

The first is resource preloading. The static resources that do not change frequently in the original QQ red packets will be distributed to various CDNs to improve access speed, such as pages, pictures, JS, etc., only dynamically changing content will be pulled from the background in real time. However, even if all static resources are distributed using CDN, it cannot support traffic floods. Therefore, the QQ team adopted a method: use the mobile QQ offline package mechanism to pre-load the red envelope-related static resources to the mobile QQ mobile terminal in advance to reduce the pressure on the CDN. There are two ways to preload offline packages, one is to put static resources into the preload list, and the other is to actively push offline packages.

The second is caching and delay. When traffic peaks come, user operation requests flow to the background at the same time, and the background server will crash. Even if the background is held up, the bandwidth and equipment resource costs required are astronomical. It is not necessary for the user to initiate a request to the background for each swipe operation. Therefore, the QQ team summarized the user's swipe times, submitted the aggregated data to the background regularly and asynchronously, and then fed the results back to the QQ mobile terminal.

Again, it is peak misalignment. Different red envelope activities are dispersed at different time points through operational means, effectively reducing the peak value of requests.

Finally, there is dynamic adjustment. The mobile QQ mobile terminal and the background of the mobile phone are not two isolated systems, but a whole. The mobile QQ system has built a complete load monitoring system. When the background load rises to the warning line, the mobile QQ mobile terminal can dynamically reduce the requests sent to the background according to the background load situation to prevent the background from overloading and avalanche.

Guess you like

Origin blog.csdn.net/m0_46163918/article/details/113810233