Difference Between Distributed and Clustered

Recently, I saw a great god's explanation of clustering and distribution on Zhihu. I feel very good. I will share it with you.

very image

The following is a serious explanation of the difference between the three structures.

Stand-alone structure

I think the one that everyone is most familiar with is the stand-alone structure. When the business volume of a system is small, all the code can be placed in one project, and then the project can be deployed on one server. All services for the entire project are provided by this server. This is the stand-alone structure.

Cluster structure

There are various explanations for the cluster mode in the programmer world, some of which make you unable to understand at all. In fact, it is a very simple thing. Let me tell you one by one.

When the single-machine processing reaches the bottleneck, you copy several copies of the single-machine, thus forming a "cluster". Each server in the cluster is called a "node" of the cluster, and all nodes constitute a cluster. Each node provides the same service, so the processing power of the system is equivalent to several times higher (a few nodes is equivalent to so many times higher).

But the question is which node handles the user's request? It is best to let the node with less load at this moment handle it, so that the pressure on each node is more even. To achieve this function, it is necessary to add a "scheduler" role before all nodes. All requests of users are given to it first, and then it decides which node to send the request to according to the current load of all nodes. This "scheduler" has a cool name - a load balancing server.

The advantage of the cluster structure is that it is very easy to expand the system. If the current system can no longer support the development of your system business, then you can add more nodes to the cluster. However, when your business develops to a certain level, you will find a problem - no matter how you add nodes, it seems that the performance improvement effect of the entire cluster is not obvious. At this point, you need to use the microservice structure.

Distributed structure

Let's summarize the previous knowledge points first.

From the stand-alone structure to the cluster structure, your code basically does not need to be modified. All you need to do is deploy a few more servers and run the same code on each server. However, when you want to evolve from a cluster structure to a microservice structure, the previous set of code needs to undergo major changes. Therefore, for the new system, we recommend that the microservice architecture be adopted at the beginning of the system design, so that the cost of later operation and maintenance is lower. But if an old system needs to be upgraded to a microservice structure, it will take a lot of work on the code. Therefore, for the old system, whether to continue to maintain the cluster mode or upgrade to a microservice architecture requires your architects to carefully consider and weigh the input-output ratio.

OK, let's start with the so-called distributed structure.

The distributed structure is to split a complete system into independent subsystems according to business functions. In the distributed structure, each subsystem is called a "service". These subsystems can run independently in the web container, and communicate with each other through RPC.

For example, suppose you need to develop an online store. According to the idea of ​​microservices, we need to split into multiple independent services according to functional modules, such as: user services, product services, order services, background management services, data analysis services, and so on. Each of these services are independent projects that can run independently. If there is a dependency between services, call it by RPC.

The benefits of this are many:

  1. The degree of coupling between systems is greatly reduced, independent development, independent deployment, and independent testing are possible. The boundaries between systems are very clear, troubleshooting becomes quite easy, and development efficiency is greatly improved.
  2. Coupling between systems is reduced, making the system easier to expand. We can expand certain services in a targeted manner. Assuming that this mall is going to hold a big promotion, the number of orders may be greatly increased. Therefore, we can increase the number of nodes in the order system and product system in a targeted manner. For the background management system and data analysis system, the number of nodes remains the original. level.
  3. Services are more reusable. For example, when we use the user system as a separate service, all the products of the company can use the system as the user system without repeated development.

Author: Daxianren Chai Maomao
Link : https://www.zhihu.com/question/20004877/answer/282033178
Source: Zhihu

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325643902&siteId=291194637