Distributed - talk about your understanding of distributed, why introduce distributed?

Without further ado, let's start right away!

Focus on:

  1. Really understand the concept of distributed systems, and have distributed system design ideas in future work.
  2. Can you consider the stability of the system in the design?
  3. Can build a high QPS robust system architecture.

1. Interviewer: Then talk about your understanding of distributed systems

problem analysis:

Various distributed frameworks emerge in an endless stream. No matter which one you use, Spring Cloud or Ali’s Dubbo, the principle is the same. Let’s examine how well you have mastered the basic concepts.

answer:

In order to solve various problems caused by the traditional single service architecture, the amount of code is huge, iterative testing and maintenance are difficult, and the entire service may be paralyzed due to a change in the test, the distributed system is to split a large service into Dozens or even hundreds of tiny services. If you compare a monolithic architecture server to a basket, then the code is the egg. Don’t put all the eggs in one basket. It is also convenient for everyone to divide and develop. The code is not in a project, and there will be no conflict. The most important thing is that the project maintains itself , how nice.

For example, Ali's Dubbo and Spring Cloud in the Spring family bucket are excellent frameworks for solving distributed microservice architectures.

2. Interviewer: What are the advantages and disadvantages of each in the distributed system environment?

problem analysis:

The advantages are obvious. The interviewer mainly wants to see and realize the shortcomings and problems, but the good aspects should be briefly mentioned.

answer:

There are many advantages. The use of distributed is not to solve various problems of traditional architecture. It is difficult for multiple people to develop and maintain under one environment, and it is not easy to control fault tolerance. It is much easier to split the problem into microservices. Mainly from four aspects briefly.

  1. System availability improvement
    A system is available 99.999% of the time throughout the year, and the service availability rate of 5 nines is not an unreachable number in a properly designed distributed system.
    When traditional centralized computing or centralized storage encounters a single point of failure, it is easy to cause the entire service to be unavailable. In the distributed service system, if a single machine fails, the entire service will not be unavailable.
  2. System concurrency improvement
    requests are distributed to different servers through Nginx load balancing. There can be one or N servers running the same code. Usually, machines will be added at any time according to the actual user visits, whether it is a database or a service. It can be expanded horizontally at any time .
    For example, during the Double 11 event, usually 50 fewer machines are enough to order. On November 1, the order volume increased sharply, and the number of servers increased to 100. Each machine is independent of each other and does not affect each other.
  3. Improved system fault tolerance

    image description


    (With a pen in hand, I can draw casually for the interviewer.)
    The same group of services is deployed in Beijing, Shanghai, and Hangzhou. If the computer room in Hangzhou suddenly loses power or fires, the traffic in the computer room in Hangzhou will be automatically distributed to the computer rooms in Beijing and Shanghai. affect user usage.
  4. Low latency 
    Referring to the previous figure, user requests from Beijing are automatically distributed to Beijing, and user requests from Shanghai are distributed to Shanghai. The server will select the computer room closest to itself according to the user's IP to reduce network delay. 

Interviewer: Well, the basic coverage is comprehensive, let’s continue to talk about the shortcomings.

Everything has two sides. Distributed services bring many benefits, but at the same time they will certainly bring troubles, mainly from three aspects.

  1. Distributed services rely on the network
    . Communication between servers depends on the network. Unreliable networks include network delays, packet loss, interruption, and asynchrony. A complete service request depends on a series of service calls. Any problem in the network of a service node may cause this request. fail.
  2. High maintenance costs
    Traditional monolithic services only need to maintain one site.
    The distributed service system is split into several small services. After the service changes from one service to dozens or hundreds of services, the operation and maintenance cost will be increased.
  3. Consistency, availability, and partition fault tolerance cannot be satisfied at the same time
    . This is the most important thing. These three characteristics are usually called the CAP theorem. In a distributed system, these three characteristics can only satisfy two at most, and cannot be satisfied at the same time. Adjust which one to sacrifice according to the actual situation.

Interviewer: Well, the third most important point is realized. (Interviewer's psychology: It would be much easier if you can realize the CAP problem. When you mention CAP, you can continue to chat)

Successfully dug a hole for yourself, about CAP, explained separately in the next section

In-depth analysis:

Regarding distributed systems, in layman's terms, the entire business system is divided into many services. The responsibility of each service is assigned to a person, and there is no code conflict between services. The service can be autonomous, and each service and technology can be selected by itself. Just follow the unified service call protocol. If you change a service for each release, then launch a service instead of joint debugging by everyone, so that the impact of changes involved in each release is also controllable. Unlike traditional monolithic architecture services, millions of lines of code are often integrated together.

 This concept was proposed by Jim Waldo in a paper entitled " A Note on Distributed Systems " published in 1994.  Interested readers can look at the original English text.

Baidu Encyclopedia explains it like this:
Distributed system ( distributed system ) is a software system built on the network . It is precisely because of the characteristics of software that distributed systems are highly cohesive and transparent. So the difference between a network and a distributed system is more about the high-level software (especially the operating system ) than the hardware.

A distributed system is not a specific technology, nor is it a specific framework. In the vernacular, it is to disperse the computing power and data storage capacity on different servers and form an overall service through network connection. Different servers may be physical machines or virtual machines. The concept of distributed can be understood as a solution plan.

In summary, a distributed system is to distribute data storage capabilities and computing capabilities to different servers and provide external services as a whole. The purpose is to solve the problem of single machine failure, single machine computing and IO performance problems, and the problem of insufficient storage space of single machine. Although the probability of a stand-alone failure is relatively small, as the scale of the cluster increases, cluster downtime and disk damage are basically the norm. The distributed system mainly solves the problems caused by various failures.

For example, Meituan Waimai, from the user’s point of view, is an app that can order food delivery, select products, pay by bill of lading, and wait for the order to be delivered after delivery. If you look at it from the perspective of a system development engineer, behind this small app is a very In a huge system, if you order a takeaway, the background will go through dozens or hundreds of service calls to complete the entire process. From a large perspective, it includes commodity management system, order system, payment system, settlement system, merchant system, distribution system, risk control system, etc. Each subsystem can be divided into several microservices, and each system logically forms a whole to provide unified external services.

3. What is the relationship between distributed systems and microservices?

Regarding distributed systems and microservices, both are just concepts. If you adopt microservices, it means that the system must be distributed. The advantages and disadvantages of distributed systems will be reflected in microservices. I personally understand that microservices are a specific solution for distributed systems.

 Summarize

 With the development of the Internet, the traditional single project can no longer meet the needs of the current Internet users. When I just graduated in 2010, I can only find a job with SSH/SSM. I don’t know about distributed, and I have never heard of it. Many software companies also A set of frameworks conquers the world. Now that era has passed, readers often ask me what language beginners learn to find a job. If you want to receive an interview opportunity from a large company and get an offer, the programming language is only the foundation, and it is also very important for the foundation of a distributed system. It should be difficult to find a job just by learning a language. All larger Internet company systems They are all distributed, and the people the company hopes to recruit are also very familiar with distributed knowledge.

Advantages of distributed systems:

  1. Improve service availability/stability
  2. Improve system concurrency
  3. Improve system fault tolerance
  4. low latency

Disadvantages of distributed systems:

  1. Relying on the network will cause system data loss or inconsistency due to network problems;
  2. System complexity, system monitoring and maintenance, and iterative release of versions become relatively complicated and costly;
  3. Consistency, availability, and partition tolerance cannot be satisfied at the same time.

Don't be long-winded, the article is over, and I look forward to three in a row!

Guess you like

Origin blog.csdn.net/qq_34272760/article/details/120714630