I don't know if you find a phenomenon. No matter what the website crashes on 12306, the ticket sales window in the ticket sales hall of the railway station is normal! What does this mean? This indicates that the Ministry of Railways has an internal network, and 12306 is just an entry point. If we compare the railway Intranet to the information highway, the 12306 website is the toll station on the highway.
Speaking of highways, there have been a lot of news over the past two days. It is said that many highway entrances have become parking lots, someone is doing exercises, walking a dog, having children, having a bowel movements, having heart disease, etc. In short, it is a mess and a crash! However, the entrance is messy, and the access to the highway is basically smooth.
Let's take a closer look at the same situation as 12306. 12306 is a scheduling level set up to prevent internal network paralysis. As a result, it is just as tragic as the expressway. It is both internal and the entrance is stuck.
Next we will take the high-speed entrance and 12306 as a problem and analyze how to solve it:
Solution 1: Split a Ticket Server for each vehicle trip.
This solution can solve the problem theoretically, but it is impossible in reality. Imagine building a separate highway between two cities in China and setting up separate entrances and exits. Of course, there will be no congestion, but is it possible? Even if cost is not taken into consideration, the Railway Department will not agree to the splitting from other aspects of management and operation.
Solution 2: distributed and large cache areas.
At present, many people have not figured out the essence of the problem. Distribution, cache, and so on are first introduced. Is there no distribution at the highway entrance? Is there no cache area?
Let's talk about the distributed problem: there is more than one entry point for High Speed in every big city. Should this be a distributed processing? Some people say that there are not many portals, but they are useless becauseNo matter how many entries you distribute, all the traffic will eventually be collected to those main roads.. As long as the traffic appears in large quantities in an instant, the traffic will eventually be blocked somewhere, but it will become blocked outside.
Besides, the cache problem: there is a small square at each high-speed entrance. It's okay to stop for a hundred or eighty vehicles. Isn't that the cache area? Some people say that the cache area is not big enough. Well, we should build a square that can stop 100,000 vehicles and then provide a matching solution to hospitals, restaurants, hotels, parks and so on. Is this cache area large enough, is it useful? There were just a few road administrators at the entrance. He kept issuing cards 24 hours a day. As a result, the staff vomited white mobs (please refer to relevant news). What is this? Isn't that a system crash?The processing capability of the entry is limited. What is the use of a large cache area????
Solution 3: queuing
The only way to do this is to queue up, but can traditional queuing solve the problem? Human patience is limited. It may be okay for average people to wait for 20 or 30 minutes. If you want to wait until the sunrise and sunset, it is estimated that anyone will crash. What if the cluster crashes? Some people started to steal the road, some people directly went to the emergency lane, some people were preparing to turn their heads in the original place, and one person did it, and then there was chaos, and the cache was completely paralyzed, if you cannot get in or get out, everyone will be there and cannot move. Same as 12306.In such an environment where there are many people, few resources, and the quality is not very high (for example, buy a ticket and dozens of people click here), the traditional queuing seems unrealistic..
Question: Why does the railway station seldom crash?
I don't know if you have thought about it. during the Chinese New Year holiday, the railway station also enters the Ticket inspection site. The traffic is much larger than the highway entrance,Why did the railway station seldom hear of crashes?
The secret lies in the departure time on the train ticket.!
For example, if the departure time of your ticket is and the current time is, it is still early and you will not block the ticket gate and execute it! You can go online at an Internet cafe, visit a store, have a meal, and have a chat with netizens. When the time is up, the alarm will remind you that you will catch up at the train station.
In the past, hundreds of thousands of people relied on an entrance. Now, both the railway station and passengers depend on a departure time, and the departure time is reversed.. Once reversed, many changes will occur:
Change 1: The ticket checking system changes the processing of traffic to active, and the amount of traffic must be processed. Now, through scheduling, the traffic can be sent in a wave of time.
Change 2: The original cache area is only as large as the waiting hall; now the whole city is a railway station cache area, and it only enters the waiting hall before boarding.
3. Change 3: The original Hou inspection and queuing are chaotic, unordered, and intolerable queues, however, it is an orderly, scheduled, and well-experienced queue.
Through the above analysis, the crux of the problem is clear:
1. In order to ensure security, stability, and unified scheduling, the internal network must set entrance checkpoints, such as highway entrances and railway station ticketing ports.This cannot be changed!
2. The processing capability of the entrance is limited, and it can only be released one by one. When the intensity is high, it may also vomit white foam and hand cramps (system crashes ).This cannot be changed.
3. The portal is passive in processing tasks, so you have to handle the tasks as much as you do, without scheduling until the system crashes.This is the only thing that can be changed.
Solution: Dependency inversion
The third reason why highway entrances or 12306 websites often paralyze themselves as entrances is:The processing of the task is passive, so you have to handle the task as much as possible without scheduling.
Since the problem is found, it is easier to solve it.
Let's talk about the highway example:
If you and I are both going to get on the highway at tomorrow, we will line up at the entrance of the highway according to the original process. Of course there are many others.
Now, we will submit the task to the highway management department one day in advance. I will receive a text message at the next day, telling me that I can leave. You will receive a text message at and you can leave. Of course, the time may not be as accurate as you have requested, but it is definitely more time-saving than getting crowded at the entrance.
Let's talk about the example of 12306:
After hundreds of millions of requests are intercepted and processed by thousands of peripheral servers, what should I do? Is one piece crowded at the entrance? Never !!
Cache all requests, and you don't have to worry about anything. Do not submit data to the central server, because there are only a few entries, and the main road may be one.
Large traffic depends on several limited resources, which will inevitably lead to chaos.
What should we do? Reverse dependency! Don't come to me. I'll come to you! The central server takes the initiative to obtain request data from the peripheral server, and then uniformly schedules and processes the data. After the processing, the central server notifies the user.
Additional benefits: Users no longer need to find dozens of relatives and friends to constantly refresh new pages!
Why? BecauseThe purpose of refreshing the page is to squeeze in the portalThe more clicks, the more likely you will be.
Now,It's useless to refresh the data multiple times. Your data is only cached.Instead of being processed. When to handle it, the central server will be uniformly scheduled.
After the order is restored and the experience is improved, the quality of everyone seems to have improved.
In fact, sometimes queuing is also a kind of happiness!