Dubbox and micro service

Dubbox and micro service

zookeeper played a role in what in Dubbo, played what role?

Now the overall architecture is shown below (assuming that the service consumer to order service, the service provider for customer service):

So what is the problem?

  1. When the service provider add nodes, you need to modify the configuration file

When one service provider is down, the service consumer does not perceive a timely manner, but also to send a request to the service downtime

This time you have introduced a registration center

Registry

Dubbo currently supports four registration centers, (multicast zookeeper redis simple) recommended Zookeeper registry, this paper talk about the realization of service registration and discovery with a zookeeper (knock on the blackboard, yet another zookeeper useful), the following general process

Now we look at the official website of Dubbo Dubbo introduction to drawing, there is no us and drew very similar

Node Role Description

Call relationship Description

  1. Service container is responsible for starting (in the above example is the Spring container), is loaded, run service provider.
  2. Service provider when you start, registration services they provided to the registry.
  3. Consumer services at startup, you need to subscribe to the service registry.
  4. Registry return address list service providers to consumers, if there is a change, the registry will be based on long push to change the data connection to the consumer.
  5. Service consumers, providers from the list of addresses, soft load balancing algorithm, choose a provider call, if the call fails, then select another call.
  6. Service consumers and providers, in memory of the cumulative number of calls and call time, time sent once per minute statistical data to the monitoring center.

 

To use the registry, you only need to change the provider.xml and consumer.xml as follows

If zookeeper is a cluster, multiple addresses separated by commas

Registration information on how to save the zookeeper?

After starting the services described above, we have observed more than a zookeeper of the root node and other dubbo, illustrated as follows

192.168.1.104 is the last node in the network address, you can configure tasks and a localhost above results, we can think about why I put the last node marked as green. Yes, the last node is a temporary node and other nodes are persistent node, so that when the service is down, the node will automatically disappear, no longer available, consumers will no longer service requests. If you deploy multiple DemoService, the following providers have several nodes, a service node holds address of a DemoService

In fact, a zookeeper cluster multiple applications can be public, such as the Storm cluster configuration and Dubbo is a zookeeper cluster, why? Because different frameworks will be built on different nodes zookeeper, independently of each other. The Dubbo creates a / dubbo node creates a Storm / storm node, as shown in

 

How the same method is called by Dubbox cluster you will need to provide load balancing mechanism. (Note:. Zookeeper themselves no load balancing, but his characteristics (those that can be found Dubbo server crashed, so as to maintain a list of callable) can make use of other methods similar load balancing capabilities achieved through mechanisms such as heartbeat consumer has made dubbo after the server list, which will randomly call a common load balancing achieved as follows:

Polling (Round Robin)

The polling algorithm each request sent in turn to each server.

The figure, a total of six six client generates a request, which requests the order of six (1,2,3,4,5,6) a. (1,3,5) the request will be sent to the server 1, (2,4,6) request is sent to server 2.

The algorithm is suitable for almost every server performance scenarios, if there are differences in the presence of performance, then the poor performance of the server may not bear an excessive load

WRR

Weighted Round-sequence is based on polling, according to the difference in performance of the server, the server gives a weight value, high performance server assigned a higher weight. For example, in FIG., The weight value of 1 is given to the server 5, the server 2 to the right is given a value of 1, then the (1,2,3,4,5) request will be sent to the server 1, (6) requests 2 is sent to the server.

Least Connections

Since the connection request is not the same each time, or Weighted Round Robin polling, it may make a large number of servers currently connected, is connected to another server is too small, causing load imbalance.

For example, the drawing, (1, 3, 5) request is sent to the server 1, but (1, 3) is disconnected quickly, this time only (5) requests a connection to the server; (2, 4, 6 ) request is sent to the server 2, only (2) is disconnected at this time (6, 4) connected to the server 2 requests. The system continues to run, the server 2 will bear an excessive load.

Least connections algorithm is to send the request to the least recently connected to the server number.

For example, in FIG, 1 is currently connected to the server the minimum number, then a new six incoming requests will be sent to the server 1.

Weighted least connections

On the basis of the least connections, according to the performance of the server for each server is assigned a weight, and then re-calculate the number of connections per server can handle according to the weight

Random algorithm

The request sent to the server random

And polling algorithm similar to the algorithm is more suitable for almost server performance scenarios

Source address hashing (IP Hash)

After hashing the source address by the client calculates a hash value of the IP, then the number of the server to obtain modulo number for the target server.

You can guarantee the same IP client requests will be forwarded to the same server, used to implement session sticky.

Guess you like

Origin www.cnblogs.com/kexinxin/p/11595213.html