First Secret! How to deal with large scale high performance barley seat selection to grab votes?

Author | Ali entertainment Henglei technical experts, senior development engineer new money

Produced | AI technology base camp (ID: rgznai100)

 

Background

With the development of live entertainment industry, various types of performances after another, more and more performances open seating, tickets to meet user demand for independent seat selection. Barley seat selection not only for small theater venues like the show, but also for major sports events, large concerts and other large venues (such as the Bird's Nest nearly 100,000).

Seat selection feature is the type of rush tickets "choose" because of "election" of visualization and large venues on the amount of data that barley is a great challenge. Through server and some solutions on the front-end to discuss how to support the ultra-large-scale venues, high-performance seat selection, by some aspects of this hope can help in some high concurrency practice for the reader.

 

the core issue

First look at the spike general merchandise, take a mobile phone spike is, under normal circumstances, only a few mobile phone models, such as affordable, high-performance file, such as the flagship, handle these goods inventory can be. For seat selection class to grab votes, all of every seat of every screening can be considered a different product, venues large and small, have a large nest 10w seat. That is a base class to grab votes on election involving 10 million level of goods, if the rush to open multiple projects at the same time, the overall number will be very large. Current product dimensions barley electricity supplier side is just the ticket stalls, seat size is not a commodity, it can not take advantage of the Group's ability to spike, seat selection class to grab votes involving electricity supplier, seat selection, ticket sales cloud, barley is a test of overall capacity.

Let's look at the whole process of seating, tickets: Tickets to JJ Changsha test project as an example.

1, the user opens the need screening project details page

 

 

2. Click on seat selection purchase, seat selection page open, view seating charts and ticket stalls

 

 

 

3. Select a grandstand area, select the preferred seats, seat selection click OK

 

             

4, the next single page, fill out the shipping address phone number, create an order

 

             

 

5, submit the order to complete the payment, ticketing. Among them, 2,3,4 links are associated with seat selection. From the process point of view, seat selection of key technologies that:

  • Fast loading seat map. In fact, the ability to read quickly load is selected seat of the page. Seat selection seat base map page to download, seat basic information (Arranging, etc.) to do the rendering, but tickets required files, the status of each seat screening to determine is locked or can be sold or have been sold. For large amount of data stadium seats 50,000 -10 10,000, rendering a seat selection page needs are great;

  • High concurrency. Due to the scarcity of hot tickets, while the number of rush tickets may reach hundreds of thousands. How to support such a high concurrency and throughput is a major test;

  • Timeliness of status updates seat when a seat sold, the need to update the status of the seat;

  • Grab votes experience: when to grab votes in the stands of a hot seat may be complicated by dozens of people try to steal, how best to enhance the user experience, as far as possible so that more users to buy a one-time success, experience better.

High-performance seat selection practice

The core requirements for high performance seat selection, we present our practice to go on seat selection class to grab votes from several dimensions as follows.

 

1. The combination of movement

The amount of data bottleneck seat selection of "bear the brunt." Logically, a seat complete show in front of the user, need to include grandstand seating, Arranging, price, sale of state and other information, bleachers, Arranging and so is constant and predictable in advance; the sale of state according to dynamic changes and so will the project. Therefore, the data strobe seat split into dynamic and static data. For large venues such as stadiums 100,000, the user opens a page selected seat, the seat of the static data (seat id, ticket id, whether fixed packages, coordinates x, y, and onstage, which stands, a few rows of numbers, etc. ), these data about 15M or so. Coupled with dynamic data such as counting speed state, color, grandstand state, the seat state, 10w stadium probably about 2M.


In other words, if we did not deal with the user only open seat selection page on the amount of data more than 17M. If the seat selection data stored on oss, if everyone downloaded 15M, 10w people at the same time you need to grab votes 1500G bandwidth and high bandwidth costs. In order to solve the problem of static file access speed, static data access directly from oss to cdn. Meanwhile, in order to protect the latest data, static data using version control.

2. preloaded static data

The above-mentioned high peak bandwidth, in order to reduce the peak and enhance the experience, the client is introduced static preloading data. Static information processing in conjunction with pre-loaded, provides a margin of time to process large amounts of data seat information, user priority display static information, users can effectively reduce the waiting time, enhance the user experience when opening the seat selection page.

Combined with analysis of user behavior by big data, determine the type of screening preloaded improve the hit rate preloaded.

 

Figure 2.1: preload adjustment flow

 

Preload + pre-parsing, data preparation completed drawing the basic information of the venue, and then the data in advance View picture seat binding, pre-rendered View and then to open the second seat selection page effect.

3. The data encoding seat

Dynamic and static data volume restricts us to achieve high throughput, but also a waste of bandwidth and service user traffic. It needs to be compressed, compressed to a certain acceptable range. Only the amount of data is small enough, only way to achieve high throughput.

1) static data encoding

In the seat handle large amounts of data (for example, one hundred thousand) preloaded only static data is often insufficient, preloaded did not have the data processing capacity of the seat problem fundamentally, at the same time for a similar multi-sports events such date multi-screening scenario, due to the existence of the cache control the amount of preload use, often affect the hit rate preloaded. The re-encoded data and use data compression is an effective way to solve the problem at the source.

Renumbering seat data, abandoning traditional xml and json format, not only can effectively compress data size, but also on data security to provide a guarantee, even if they are to get the interface data because of the lack of data coding protocol, can not obtain a valid original information .

2) seat static data compression overall framework

Currently barley for their specific seats data characteristics, combined with efficient binary coding scheme renumbered seat data code, and then use the generic lossless compression to further reduce the volume of data, thereby reducing the network transmission time seat data, from the root to solve large on this data transmission delay problems caused by:

 

Figure 3.1: static data compression process

 

Encoded binary data based only ensures the data security, but also ensure the efficiency in data analysis, even if the use of data compression also has less delay than parsing json, xml's. While both tools of mass production mode, and further solve the problem of building data.

             

Figure 3.2: static data compression tool architecture

 

And the negotiation process by the server-side end of the handshake to realize data compression encoding and flexible general composition, Sever corresponding compression end may be issued for different file formats end:

Figure 3.3: static data compression, handshake negotiation workflow

 

CRC combined with the idea to develop a compatible IOS, Android and vertical hash check based on the properties of H5 seat three-terminal. Compared to other common md5 hash calculation, when processing 60,000 seat multi-dimensional information, at the end to achieve a dozen milliseconds, detecting the total amount of data of about 50 milliseconds H5 sides, such that the case does not take much time to You can verify the accuracy of tens of thousands of class seating resolution. After this the complete coding link detection, the volume of data reduction realized at the same time, while maintaining the ratio of traditional and json xml efficient parsed data, high security.

 

    

Figure 3.3: Comparison of compressed data

 

Wherein the quantum is the end from barley and grinding dynamic bit dictionary compression algorithm, in combination with a large Matt business scenario, to achieve a high compression ratio and fast data analysis:

 

Figure 3.4: quantum compressed file structure

 

3) dynamic data encoding processing seat

Difficulties a) dynamic data

Seat selection dynamic interface mainly related to ticket stalls, the grandstand, the seating state. The maximum amount of data that is the seat of state. With a 50,000-seat stadium, for example, each seat must return to a state in which the tip rendering. Using seat id and status of the key, since the seat so that the entire return results more is too large, 50,000 seat stadium data back to the above 1M.

If the page needs to open a seat selection 1M amount of data throughput, the basic interface is not available. Before the policy is in accordance with the grouping strategy, about 50,000 will be divided into 10 groups, each request so the amount of data about 100k, so as to achieve the basic interface is available, but need to request 10 times on end to get the status of the entire screening can think and know how much impact performance. If the 50,000-seat stadium, 100,000 peak rush tickets, then this interface will only need 1 million qps, it certainly will grab every hanging.

b) Program

Currently interface is the premise by mtop agreement, we think: mtop currently does not support byte [] array stream, only supports json string structure format. How to reduce the data returned, try using a simple program, called once at the same time return the entire stadium seating state, the direction of our efforts.

Large amount of data is mainly because there are a lot of redundant seat id. There is no way not to rely on these seats id? Since we do static and dynamic separation, static data already covered seats id, dynamic interface where we only need to return to the state corresponding to that state in order to return the seat still inside. We return to the simple result of merging neighboring state will further reduce the size of the results returned. Assume that the user selected seat seat normally distributed, and the average length of an average return of less than 5w seat 20k.

Of course, if we mtop protocol supports a binary stream, then we can be stored with a bit bit, you can further reduce the size of the returned result.

4. Efficient Cache

1) Cache

For such a high TPS, tair is the best choice. Tair + using local cache, the data to support such a high peak. He mentioned tair, to mention some of our policies here. User page into the seat selection is one of the stands, we have designed a stand cache, namely stand-level cache; a user will be selected seats, we also added a seat cache, is the seat size of cache. Two cache to protect the user to check the stands and the user can hit the radio base cache. standcache hot key, allowing near real-time data from the non-scene seat selection, so the introduction of tair localcache and guava localcache to increase throughput, thereby reducing pressure on the reading of tair.

2) protect the downstream system

Currently uses a strategy of using a call to the downstream lock, tair global lock. Before going to get the lock request ticket cloud bottom data. I got locked in the process to update tair cache. In fact, from here on tair write or qps relatively small, but each competition read lock on tair or not too small. By using the local lock tair + random permeability came to reduce lock-consuming read qps. In order to do downgrade downstream dependency, increased data snapshot, record every call to the downstream data snapshot. When the snapshot before the adoption of a particular call failed to compensate.

3) guarantee timely data updates

Because we use a tair global lock, you can control the downstream invoked in the second grade. Call asynchronous trigger. It will trigger the shortest 1s we initiate a call to the downstream. If we want to maximize the use of cloud-ticket inventory capabilities, giving users a delay in less than 1s, we have some strategy. Get the call data update tasks within 1s thread lock, do some tasks in the data update strategy, initiated within 1s 1 multiple calls on the ticket or the cloud, the more calls tair more timely updates. Since the user has a certain seat selection operation, the user delay is 500ms in general substantially no perceptible.

4) buffer cache warm-up warm-up look, the user experience and system performance helpful. Grab votes projects using certain strategies do automated pre heat.

 

5. Security and Disaster Recovery

1) Safety

Look barley seat made from the above data encoding and encryption, and storage paths do confusion, not to protect the open seat race against time data can not be cracked, to protect the safety seat selection data. Moreover seat selection page layout prevention and control strategies, security is a real need to click on the seat in order to complete the order, to prevent the brushes to prevent bypassing seat selection direct orders. By a similar strategy reduces the seat selection of invalid traffic, improve the stability.

2) Disaster Recovery

Seat selection is mainly made disaster in the following areas. Static data is stored in the OSS, currently used storage regional disaster recovery; Tair used standby cache buffer may be made when the handover failure; pc and the wireless server cluster made isolation.

 

to sum up

In this paper, data processing, seat selection performance, caching, and so forth up some practical strategies barley Performance Option seat. Through these practices barley can easily carry hundreds of thousands of items to grab votes currently top traffic.

【end】


Welcome to all developers under the Fanger Wei code scanning fill out the "big developers and AI research", just 2 minutes, you can harvest value of 299 yuan, "AI developers million people congress" live online tickets!

推荐阅读全球呼吸机告急!医疗科技巨头美敦力“开源”设计图和源代码使用大batch优化深度学习:训练BERT仅需76分钟 | ICLR 2020
互联网之父确诊新冠,一代传奇:任谷歌副总裁、NASA 访问科学家
微软为一人收购一公司?破解索尼程序、写黑客小说,看他彪悍的程序人生!在Kubernetes上部署一个简单的、类PaaS的平台,原来这么容易!2020年,这20个大家都认识的加密交易所过得怎么样?你点的每个“在看”,我都认真当成了AI
Released 1375 original articles · won praise 10000 + · views 6.85 million +

Guess you like

Origin blog.csdn.net/dQCFKyQDXYm3F8rB0/article/details/105354903