As one of the world’s recognized real-time trading systems with the largest scale and the busiest in a certain period of time, it can ensure smooth operation for most of the time, and 12306 is quite difficult.

Editor’s note: This article is from WeChat public account “ PingWest product play ” (ID: wepingwest), author Li Hezi.

Near the Spring Festival, 12306 collapses once, and someone breaks the heart once.

On the morning of December 23, many netizens broke the news that 12306 had failed to load trains, could not buy tickets, or got stuck in the waiting order payment interface. It was suspected that the server crashed due to too many people grabbing tickets. 12306 customer service responded later. The reason may be that there are too many operating passengers and the system is busy. You can try to uninstall and install the client again or switch networks. As for whether the technical support will be strengthened during the Spring Festival, customer service said that they need to feedback to the relevant technical departments to know.

It seems that in the Spring Festival Festival every year, 12306 always drops a few times. Some people have learned to play in pain, and some netizens thought that they might report to a travel agency to go home:
I ca n’t grab the ticket to go home, it ’s really not 12306 technology

Although many people always shout that the New Year is too annoying and tiring, they still have to return home. In accordance with the 2020 Spring Festival train ticket network ticketing sales policy 30 days in advance, December 23, 2020 tickets can already be purchased on January 21, 2020, which is the peak period of ticket rush. With only a full month to go before the Spring Festival holiday, most of the people who feel resentful are still very anxious by this wave of downtime.

Every downtime is accompanied by a curse, and this time is no exception. You don’t understand why so long passed, 12306 is still so disheartening. This problem is not simple. It involves China’s complex national conditions and the technologies behind it. It is not easy to say in a sentence, and we cannot ignore it.Easy to characterize 12306.

But one thing is certain, as one of the world’s recognized largest and most busy real-time trading systems in a certain period of time, it can ensure smooth operation for most of the time, 12306 is already quite difficult.

Why can’t I get tickets?

Before explaining why 12306 crashes this time, we need to understand some of its basic rules.

For a long time, there has been a ticket sales model in China ’s railways called “restricted sales” . It is a continuation of the cardboard ticket sales model to a certain extent. In the era of cardboard tickets, the tickets sold by each car at each station and in each section need to be printed in advance, so the ticketing department will give each train differently An indicator for the number of tickets in a section.

In the Internet era, this kind of indicator allocation still exists, so there is gradually a statement that the range is restricted. This ticket sales model follows the principle, 12306 official External explanation is “abandon short guard” .

For a simple example (only for the sake of illustration, it does not represent the real situation). For the G1 high-speed trains starting from Beijing, passing Jinan, Nanjing, and finally to Shanghai, there is a high probability at the beginning of ticket sales. Tickets from Jinan to Nanjing will not be sold, or the number of tickets sold in this section will be limited at the beginning (not all tickets will be released) in order to ensure the travel needs of long-distance passengers from Beijing to Nanjing and Shanghai.

Because once you buy a ticket from Jinan to Nanjing, it means that you not only occupy a seat from Beijing to Nanjing, but also from Beijing to Shanghai. Regardless of whether it is convenient for long-distance passengers (no one wants to change three seats from the third section of Beijing to Shanghai) or to reduce the workload of the railway system, the limited-sale section is currently the most suitable solution.

This also explains to some extent why train tickets are difficult to grab. On the one hand, it is a huge population base, and on the other hand, it is a measure to limit sales. All of these tickets have been stopped as soon as they are released. Although in the near period of driving, in order to regulate demand and increase train utilization, some unsold remaining tickets will be released to limit sales. However, when transportation resources such as the Spring Festival are extremely tight, people ca n’t buy more tickets a day. Worrying for a day, hurting money and feelings.

The more you work hard, the more profitable third-party ticket grabbing software is. More and more people choose to give up12306 official website and App manually book tickets, and in turn entrusted the task of snatching tickets to Ctrip, Zhixing and other third-party software and machines.

Manual refresh is never faster than a machine. Third-party ticket grabbing software brings a huge and more frequent amount of data to 12306. An anonymous user who has worked in the train ticket department of third-party software recalls this, “As for the traffic we traffic to her every day (12306), basically the small e-commerce website will crash, and we proposed earlier Replenish tickets at stations, buy short-distance tickets for extension, provide a series of solutions for air tickets plus trains and cars, the query volume is very large. ”

Why does 12306 crash?

The pressure that third-party ticket-grabbing software brings to 12306 is basically in the remaining ticket inquiry link. This is where 12306 collapses.

The query link involves the complexity of the 12306 inventory mechanism. In fact, as early as 2014, a former Taobao engineer with the ID “Code Dog” posted a post on the famous forum “Xixihe” to express his views on 12306. He once thought that the 12306 system was easy to set up, so he launched an open source project called “Designing a System for 12306”, but the practice at work completely changed his understanding of 12306.

The complexity of the 12306 system is that its SKU (that is, the Stock keeping Unit) is not like ordinary e-commerce. It can be calculated simply by distinguishing between the presence and absence of goods, but requires Combining different sections of each line to do complex calculations, and the SKU of 12306 still changes dynamically at all times.

Here is an example of the “G71” high-speed train from Beijing West to Shenzhen North (only the model of the theoretical world is discussed). This train has 17 stations and 3 types of seats. On the surface, these are 3 types of products (business seats, first-class seats, and second-class seats), but in fact, there are as many as 408 types of G71 products (note: Is the type of product, not the specific number of products).

The calculation method is that if you sell tickets from Beijing West, there are 16 selling methods, because there are 16 stops behind, namely, Beijing West to Baoding, Shijiazhuang, Zhengzhou, Wuhan, Changsha, Guangzhou, Humen. …… Each section can be viewed as a separate commodity. Similarly, if it starts from Shijiazhuang Station, there are 15 selling methods, and so on. Therefore, according to the station interval alone, the G71 product types are: 16 + 15 + 14 + … + 2 + 1 = 136 types. Taking into account the three seat types, the product category becomes: 136 * 3 = 408.

Let’s look at G again71 how to reduce inventory. If passenger A buys a ticket from Beijing West to Baoding East (that is, the next stop in Beijing West in sequence), then the SKU of G71 will be reduced by 16, including Beijing West to each of the remaining 16 stations Should be reduced by 1 (note: this refers to the number of goods, you can temporarily ignore the type of seat).

Similarly, if passenger B buys a ticket from Beijing West to Shenzhen North (that is, the terminal), the SKU of G71 will be reduced by 136, including Beijing West to the remaining 16 stations each. The interval is reduced by 1, the remaining 15 stations from Baoding East are reduced by 1 each, and the remaining 14 stations are reduced by 1 from Shijiazhuang … so the subtracted inventory is: 16 + 15 + 14 + … + 2 + 1 = 136 Each.

G71 has enough product categories, and inventory is even more tedious. It can be seen that the dynamic inventory of 12306 is much more complicated than the inventory mechanism of any website we usually buy. Equivalent to every ticket purchased by a passenger, 12306 needs to update all ticket data of the corresponding line < / strong> .

According to industry insiders, there is a huge amount of visits to the remaining ticket query system, accounting for more than 90% of the total website traffic of 12306. Concurrent requests are intensive during peak business hours, and performance requirements are the most important part of the entire business system.

A crash occurs when third-party ticket grabbing software plus manual querying floods the amount of data beyond the computing power of 12306.

Not 12306 without effort

For 12306, there are only two ways to deal with it, one is to fight against third-party ticket grabbing software, and the other is to upgrade the server. In fact, these 12306 have long been thought of.

In order to crack down on ticket-grabbing software, the method tried by 12306 includes the earliest alphanumeric combination verification code. Later, there are many graphical verification codes. It is stipulated that you cannot delete common contacts within six months. Each registration ‘S account must be verified by real name, as well as the “official ticket rush function” standby ticket purchase.
Can't grab the ticket to go home, it's really not 12306 technology

▲ The graphic verification code of 12306 was broken

How to go through it, the reason is not repeated, but the result is that all kinds of complex restrictions can always be solved by third-party software. This is not the case now. ), And the alternate function of 12306 was just officially launched in May this year.

For server, 12306 has two major upgrades for the remaining ticket query system.

One time, I chose to cooperate with the American technology company Pivotal within one year after the launch, and introduced the latter’s GemFire ​​distributed memory computing platform technology to take the lead in querying the 12,306 remaining ticket query system. Make a transformation. The concepts of “distributed data processing” and “centralized data processing” are relative. Distributed computing is more advantageous in solving the ticketing problem of 12306 (friends who do not understand the difference between the two should search by themselves). The technical transformation effect was obvious, and 12306 was relieved temporarily.
Can't grab the ticket to go home, it's really not 12306 technology ▲ 12306 After the introduction of Pivotal GemFire ​​transformation results

The other time was a collaboration with Alibaba Cloud. According to an anonymous user who claims to be an Alibaba Cloud programmer and participated in the 2015 12306 Spring Festival project, the two teams have begun to discuss how to put the remaining ticket query system on the cloud in early 2014, and in the 2015 Spring Festival During the period, 12306 75% of the remaining ticket inquiry business was placed on the cloud.

Compared to the memory-based distributed cluster system such as GemFire, cloud computing is one step further. In terms of improving the ability to query the remaining tickets, cloud computing can quickly deploy applications and provide services. Through minute-level capacity expansion, ten Expansion of service capacity by 100 times and 100 times.

Knowing this, we really can’t blame 12306 for not working hard. . In particular, considering that the number of trips to the Spring Festival Railway, which is constantly increasing every year, is constantly increasing, 12306 faces a big test almost every year.

It is obvious to put together the railway spring transportation data for the past five years. The total number of passengers sent by the spring railway from 2015 to 2019 is 295 million, 326 million, 357 million, 380 million and 410 million. . According to a video conference held on December 25 by the eight departments including the National Development and Reform Commission, the Ministry of Transport, the Ministry of Public Security, and the National Railway GroupIt is predicted that the number of passengers sent by the Spring Festival Railway in China will reach 440 million in 2020.

You may ask, in this case, why not buy more servers for 12306? Someone gave an example of this:

“During the Eleventh Golden Week, the road from Beijing’s main city to the Badaling Great Wall was tight and tight, but it was not possible to repair this road as a 10-lane highway like An’an Street because of peak travel during the Golden Week. It cost a lot of money to build a road, and the Golden Week can soar to 80 km / h. But usually, it is used to lay millet on the residents on both sides? Force 12306 to buy a lot of servers to deal with the Spring Festival, and force Beijing to build a 10 lane Highway to Badaling Great Wall makes a lot of sense. “

Furthermore, even if you buy more servers, China’s current railway capacity is still there, and there will still be people who can’t grab the tickets.

So don’t let go of the grievance that “12306 technology is not working”, it doesn’t make sense. As a 12306 engineer said when reviewing the system just online, “In fact, we know that they are not scolding 12306, they are scolding this era.”