当前位置:网站首页>Liuyongzhi: one code communication defect analysis and architecture design scheme - sound network developer entrepreneurship lecture VOL.02

Liuyongzhi: one code communication defect analysis and architecture design scheme - sound network developer entrepreneurship lecture VOL.02

2022-06-09 08:08:00 Acoustic network

This article is based on 「 Sound network developer entrepreneurship Lecture Vol.02」 Share your speech , Shared by Thoughtworks Expert consultant liuyongzhi . You can click here link , Watch the video playback and download the instructor PPT.

From the end of last year to now , With the recurrence of the epidemic , The one code communication system in many cities has failed , This proves that there are still some technical deficiencies in the one code communication system , So this sharing will introduce how to use PAST Problem solving framework , Research and solve these problems from the aspects of architecture and design .

01 PAST Problem solving framework

PAST The first word of P yes Problem, It represents the problem . When there is a problem , Don't rush into the program phase , Research and analysis should be carried out first , Identify what the problem is . This is also Eric Evans Of 《 Domain-driven design 》 Mentioned in , Understanding the target domain and integrating the learned knowledge into the software is domain driven design (DDD) Top priority , This underscores the importance of the problem .

The second word A yes Analysis, It represents the analysis of contradictions . There may be many reasons for the problem , In this process, we should first find out the primary and secondary contradictions , Then for these reasons or contradictions Find the corresponding Solution, That is to say S. here , You can list the solutions first , then stay Tradeoff Stage to make trade-offs . In the practice of software or architecture design , Most of the time I'm making trade-offs , Not decisions , Therefore, the design needs to be selected , Finally, the plan is worked out . According to different schemes , You may have to take advantage of the situation , In the final stage of the effective review.

02 Problem problem

The following figure shows the one code communication system of a city . Suppose the place of production is Xihong city , chart 1( Left ) It is a normal one code communication system , Include name 、 ID number and QR code , The two-dimensional code is divided into green code 、 Red or yellow . in addition , chart 1( Left ) The following section also contains vaccination information and 15 Nucleic acid test results within days . It can be seen from the picture that , The main entrance of the one code communication integrates many functions . chart 1( Right ) It is the fault display page of the one code communication system on Monday morning , Display the one code communication system blank , Besides , There is also a problem that the nucleic acid test results do not show any information .

 picture

■ chart 1

03 Analysis analysis

3.1 The main contradiction

In the analysis phase, we need to try to investigate and analyze these problems , Find the cause and contradiction of the problem . At this time, a large number of citizens need to open the nucleic acid proof page of the one code communication system from different occasions on Monday morning , And the one code communication system can not meet the contradiction between large concurrency at the same time . The one code communication system cannot be opened , Causes users to refresh repeatedly , System user requests soared . here , Requests may reach the background or even the service layer directly , And then go into distributed cache Or database , This creates The traffic of the back-end server increases suddenly , The corresponding network bandwidth increases .

3.2 Architecture analysis

Next, we will further analyze the architecture and design , At the data level , There may not be a good caching mechanism , Many query requests go directly to the server ⾄ database , Cause cache breakdown , A lot of traffic is “ resentment ” To the database . In terms of frequency elasticity of change , The problem with the one code communication system is , individual ⼈ Code page ⾯ Aggregated too much content , There is no container based cluster construction and circuit breaker mechanism . from CFR Cross functional requirements , The problem lies in , Developers do not consider the peak limit of the server when designing the service , Performance and pressure are not well done in the system test and design stage ⼒ test , Eventually, the system is overloaded . from ⽹ Network bottleneck , In theory 1000M ⽹ The transfer speed of the card is 125MB/s,100M ⽹ The transfer speed of the card is 12.5MB/s, The willingness to fail on the same day may be that the network bandwidth is not enough to support , Causing bottlenecks on the network .

 picture

■ chart 2

04 Solution Scheme enumeration

After the analysis is completed, the problem solution needs to be developed , During scheme enumeration , Don't rush to express your inclination , Alternatives should be identified first , And arrange and combine them .

4.1 Based on data layered architecture

For data , Can be divided into UI Layer personality data 、 Cache data and DB Full data . Cache design follows the principle of proximity , The closer the data is to the user, the better , The performance may be better . According to this principle , Data based layered architecture is actually a funnel architecture , It is a caching policy based on objects and collections , Reduce access to lower level systems . For each layer of data , It can be handled in different ways .

about UI Layer personality data , In terms of the problems of the one code communication system , When the user clicks to query the nucleic acid results , You can disable the button , It is functionally forbidden to submit repeatedly , Setting up 15 Seconds before opening , This will block the flow . For cached data , It can be cached in the browser , For example, common pictures 、 Static files 、 The script is cached , This may require only limited resources to allow the request to proceed to the corresponding subsequent phase . Besides , It can also be used CDN Cache distribution network . Data from UI Layer arrives at the application layer or the server , May adopt NGINX Or the intermediate server acts as a proxy , For example, on the server side, for frequent queries , But modify less data to create a cache .

about DB Full data , Focus primarily on storage , Instead of doing complicated calculations . Database manufacturers can support database current limiting , When a certain flow rate is reached . Returning the corresponding exception code will tell the user that it is not available , The corresponding server can fuse according to the situation , Instead of letting the database process information all the time without being able to respond , This will cause the entire application to crash . in addition , When there was a problem with the one code communication system that day , It is a good choice to establish different microservices to dynamically and flexibly expand the capacity of nucleic acid reports , The means of division is DDD.

 picture ■ chart 3

4.2 Frequency and flexibility of business changes

In the process of entrepreneurship or in some more complex systems , You can do some experience design , Divide the system business capability . Be context based , Judge whether to switch from single service to micro service according to the business capability of the system . in addition , Also consider the frequency and flexibility of business changes , For example, nucleic acid detection is a recently used function , Put it on the home page , After entering the system, you can directly query . It turns out , At that time, Xihong city directly put the function of nucleic acid detection on the page a few days after the outbreak , This indirectly shows that the business change frequency is very important to the system design .

 picture

■ chart 4

4.3 CFR – Test design and performance

in the light of CFR Come on , chart 5 Show the instructive four quadrant test .Q1 Quadrant supports the whole test of the team from the perspective of technology , Including unit test and component test , It can help the team find problems as soon as possible .Q2 Quadrant supports team testing from a business perspective , Focus more on finding functional and business problems .Q3 Quadrant evaluate products from a business perspective , It mainly includes some exploratory tests .Q4 Quadrant evaluates products from a technical point of view , Including performance testing 、 Stress test and safety test . Can be 4 The four quadrants are divided into quality delivery (Q1、Q2、Q3) And operation and maintenance (Q1、Q2、Q3、Q4) Two guidelines . With DevOps The prevalence of , These four quadrants are often combined , Develop effective testing strategies , Enable test and development to be implemented in the project .

 picture

■ chart 5

In terms of performance design scheme , In the case of high concurrency , For example, one second has 100 A request , Then whether to put 100 Requests are put directly into the server and database , Conduct 100 Queries ? Obviously not , The solution should be to combine these requests . Requests can be grouped together in the form of timers or timers , Find the corresponding after the query API Return accordingly . This is actually a variant of batch query . But if there are fewer requests , There is no need for request consolidation , It should be configured according to the situation . Another method is called current limiting , You can use Token bucket algorithm , The capacity of token bucket is ⼀ Set the , As a token ⼀ Added at a fixed rate , If the bucket is full , You will not continue to add . You can also use Leaky bucket algorithm , No matter how many concurrency there are currently , Pass out ⽔ The number of requests received by the rate guarantee daemon is ⼀ Set the , Current limiting can be achieved ⽬ Of . This method is not applicable to one code communication system events . Middleware current limiting method yes Tomcat send ⽤ maxThreads To achieve current limiting , It can also be done through NGINX Of limit_req_zone and burst To achieve rate current limiting ,NGINX Of limit_conn_zone and limit_conn Two instructions can control the total number of concurrent connections .

4.4 Network bottleneck

From the perspective of network bottleneck , To prevent network congestion , You can try to change the access mode from HTTP become TCP, For example, to access Redis cache , In this case ⽤ RESP ⽅ type . You can also make ⽤ more ⾼ Classy ⽹ card , Take for example ⽤ DNS Load balancing , Make more than one IP Corresponding to ⼀ Domain names .

05 Tradeoff Trade offs and trade offs

To do software is to do trade-offs . say concretely , After the front end lands , Client cache 、 Browser cache 、CDN Cache, etc. can be started , First access the server , The server here contains the corresponding NGINX Or load balancer , The traffic then reaches the application layer and the service layer , If the flow is large at this stage , Multi line performance optimization or high-performance RPC, You can also add a cache . Then you can enter the microservice framework .

Back to the cache section , The data access layer may contain Redis etc. , Some frequently accessed but infrequently changed data can be cached here , Reduce by requesting a merge or query I/O. In the storage layer , The database pays more attention to full data , If the database is under great pressure , You can consider sub database and sub table . According to different data , Even different people 、 Different areas , Can set up their own database to access . In terms of infrastructure , The system should be able to support rapid capacity expansion , If the frequency elasticity of business changes is taken into account , So cloud primordial is indispensable . Finally, a scheme is listed for reference only .

 picture

Q & a session

1、 How to lead and manage the technical team of start-ups ?

To lead a team , First, you should determine the direction of the team , That is, the project vision . The goal comes after the vision is defined , Then according to the actual situation , Identify the skill requirements of the personnel needed to support these goals . secondly , The team should improve its ability , Because to achieve business goals , Corresponding capability output is required . in addition , If there are more team members , There should also be team norms , Make the strategic process of the company or project , Process instrumentalization . For organizations , I think we should keep trying to learn , The pain points should be solved from the perspective of the customer .

2、 One code communication system CDN What are the design principles ?

In general , When configuring , Be clear about what can be cached . such as , You can put infrequently accessed and infrequently changed data into CDN In cache , The details should be determined according to the business data .

3、 Request how to merge ?

stay Java There is feature Functions can introduce requests . such as ,1 Seconds 100 A request , After the request is introduced, it can be divided into 10 Share , Traverse through the thread pool in one second 10 Time . Specifically, you can add requests to the thread pool separately , Then the thread pool triggers the call request at a fixed time .feature The function makes the request return from the database , Be able to find the corresponding request. For these questions ,JavaSpring There are already mature schemes in .

原网站

版权声明
本文为[Acoustic network]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/160/202206090755594664.html