Dubbo---Distributed (RPC) basics

1. Distributed basic theory

1. What is a distributed system

A distributed system is a collection of several independent computers. These computers are like a single related system to users. A distributed system is a software system built on a network.

2. Development and evolution

Insert picture description here

3. Software architecture

(1) Single application architecture
  • When the website traffic is very small, only one application is needed and all functions are deployed together to reduce deployment nodes and costs. At this time, the data access framework (ORM) used to simplify the workload of adding, deleting, modifying and checking is the key.
    Insert picture description here
  • Advantages: suitable for small websites, small management systems, all functions are deployed into one function, simple and easy to use.
  • Disadvantages:
  1. Performance expansion is difficult
  2. Not conducive to multiple people developing at the same time
  3. Not conducive to upgrade and maintenance
  4. The entire system takes up a lot of space
(2) Vertical application architecture
  • When the number of visits gradually increases, the acceleration caused by the increase of a single application by the machine becomes smaller and smaller, and the application is divided into several unrelated applications to improve efficiency.
    Insert picture description here
  • advantage:
  1. Separation of interface + business logic
  2. Reduced the difficulty of maintenance and deployment
  • Disadvantages:
  1. Applications cannot be completely independent, and a large number of applications need to interact
  2. Common modules cannot be reused, waste of development
(3) Distributed service architecture
  • When there are more and more applications, the interaction between applications is inevitable. The core business is extracted as an independent service, and a stable service center is gradually formed, so that front-end applications can respond more quickly to changing market demands. At this time, to improve business reuse and integrationDistributed Service Framework(RPC) Is the key. Distributed systems treat services as independent applications to realize service sharing and reuse.
    Insert picture description here
(4) Mobile computing architecture
  • When there are more and more services, problems such as capacity evaluation and the waste of small service resources gradually appear. At this time, a dispatch center needs to be added to manage cluster capacity in real time based on access pressure to improve cluster utilization. At this time, the resource scheduling and governance center (SOA) [Service Oriented Architecture] used to improve machine utilization is the key.
    Insert picture description here

4. What is RPC

  • RPC [Remote Procedure Call] refers to remote procedure call, a method of inter-process communication, a technical idea, not a specification. It allows the program to call a procedure or function in another address space (on another machine on the network) without the developer explicitly coding the details of the call. Calling a local method is the same as calling a remote method.
(1) Basic principles of RPC

Insert picture description here
Insert picture description here

(2) RPC call process

A. The caller client wants to use the functions (methods) of the server on the right to initiate a method call.
B. The client stub is a stub defined in the PRC and is regarded as an assistant to the client. The stub serializes the method parameters to be called, and wraps the method name and other data.
C. The client stub finds the service address, and sends the details of the method call to the server on the right through the network socket (network communication technology).
D. The server receives the requested method name, parameters and other data through the socket and sends it to the stub.
E. The data received by the server is processed by the serverstub (the server's assistant), the real method of the server is called, and the service is processed.
F, the server method is used to process the business, and the processed result object (Object) is handed over to the assistant, and the assistant performs the Object Serialization, the object is converted to binary data.
G. The server assistant binary data is delivered to the network processing program
H, and the binary data is sent to the client through the network.
I. The client receives the data and hands it to the client assistant.
J. Client assistant, the received data is deserialized into a java object (Object) as the result of remote method invocation.

(3) Expansion: What is serialization and deserialization
1. The definition of serialization and deserialization:
  • Java serialization refers to the process of converting Java objects into byte sequences
  • Java deserialization refers to the process of restoring byte sequences to Java objects
2. Data transfer of json/xml:
  • Before data transmission (also called network transmission), the Java object is serialized into a json/xml file through a serialization tool class.
  • After data transmission (also called network transmission), the json/xml file is deserialized into the object of the corresponding language
3. Summary:

The core role is the preservation and reconstruction of the object state. (The core point of the whole process is the object state and description information stored in the byte stream)

Two, dubbo framework

1. Overview of dubbo

  • dubbo is a high-performance, lightweight open source Java RPC framework, which provides three core capabilities:Interface-oriented remote method invocation, intelligent fault tolerance and load balancing, and automatic service registration and discovery
  • dubbo is a distributed service framework dedicated to providing high-performance and transparent RPC remote service invocation solutions and service governance solutions.

2. Basic structure

Insert picture description here

Service Provider (Provider) : The service provider that exposes the service. When the service provider starts, it registers
the service it provides with the registry.
Service consumer (Consumer) : The service consumer that calls the remote service. When the service consumer starts, he subscribes to the registry for the service he needs. The service consumer selects the service from the provider address list based on the soft load balancing algorithm. One provider makes the call, and if the call fails, another call is selected.
Registry : The registry returns a list of service provider addresses to consumers. If there is a change, the registry will push the change data to the consumer
monitoring center (Monitor) based on the long connection : service consumers and providers, in memory Accumulate the number of calls and call time, and send statistical data to the monitoring center every minute

Call relationship description

  1. The service container is responsible for starting, loading, and running the service provider.
  2. When the service provider starts, it registers the service it provides with the registration center.
  3. When a service consumer is started, he subscribes to the registry for the service he needs.
  4. The registration center returns the list of service provider addresses to the consumer. If there is a change, the registration center will push the change data to the consumer based on the long connection.
  5. Service consumers, from the provider address list, based on the soft load balancing algorithm, select one provider to call, and if the call fails, select another to call.
  6. Service consumers and providers accumulate the number of calls and call time in the memory, and send statistical data to the monitoring center every minute.

3. Dubbo environment construction

Please move to the next blog post!!!

Guess you like

Origin blog.csdn.net/hcz666/article/details/115054496