Event phenomenon
On December 20, Xi ‘an Yiyitong crashed, and a large number of jokes appeared on the Internet. For example, the health code cannot be opened, so you need to take a screenshot of the health code and swear to enter the company. For example, the developer who maintains one code can’t get into the software park because he can’t open the health code.
Afternoon to respond to the call of the government to do nucleic acid, row in need of three or four eyes to see the head of the position, people kept asking each other: “your code can brush out?” “My code also brush not to come out, estimate the system is broken, perhaps for a while restart under good.”
Half an hour later, the line for the test suddenly became restless. I stood on tiptoe and saw the line in front of me start to break up. Then I heard a message from the front: “System problem, suspend testing!” But leave of I, ear spread do not know who shout of one voice: “lane scatter li”.
This voice is very harsh, no other, because they are both XI ‘an IT people.
Collapse cause analysis
While refreshing a code pass, while falling into the vortex of analysis.
The interface of the small program came out, proving that the front-end static resource loading is not abnormal. Although there is no log for analysis, it can be identified as the collapse of back-end service caused by excessive interface pressure based on common sense.
But tens of millions of people in Xi ‘an don’t care if your back end collapses or not. Because the health code loading failure, most of the citizens will choose to reopen the small program, and this caused the interface call volume exponential growth, so that the original is not rich server resources even worse.
So what can the front end do?
What does the front end do
If you stay in an industry for a long time, you will inevitably have a sense of substitution whenever you encounter bugs around you. Although their own two knife technology, even participate in the health code development opportunities are not.
1. Handle exceptions
The main reason for the crash from an interface point of view is that the interface returns an exception, in which case the exception is not handled by the front end.
Catching and handling exceptions returned by interfaces is a basic front-end etiquette. When the interface is abnormal, the user is informed of the failure to open this time through the error page, and the user is reminded or forced to refresh frequently through interactions such as countdown.
This simple interaction alone can reduce a lot of interface stress.
2. Ladder display
From the interface analysis, it is found that the front-end logic implementation does not load the health code, vaccination status and nucleic acid detection status in batches. It is this kind of loading mode of one shuttle that leads to the collapse of all parts.
Assuming that the back-end microservices architecture already exists, the front-end reason asynchronously loads the three sets of data from different microservices based on priority. The state of vaccination and nucleic acid test is even changed to trigger loading, that is, the health code is preferentially displayed, and the trigger button is added to the position of the original vaccination and nucleic acid test state.
3. Front-end cache
Through the past use, basic can confirm the personal health status is not real-time update.
As such, an individual’s health status should utilize the front-end cache between calculations. Although the nucleic acid and vaccine status is different from the health status, front-end cache can also be utilized by front-end cache + trigger update, that is, when nucleic acid test and vaccine vaccination scan code, the front-end cache is cleared and the cleared state is maintained until data update.
The above approach has the same principle: use a front-end approach to reduce unnecessary flushes and thus reduce server stress.
Everything will be ok
The best way to prevent system collapse is to tap the keyboard in daily life. In daily work, there will be less so-called low-level logic, top-level design and process grasping, and more optimization time will be left for migrant workers in the new era.
There is no insurmountable winter, and everything will be solved. I am writing a program for a pie: a play legend like sesshomaran front-end development, GridManager author.
Come on xi ‘an!