What is RPC?
Remote Procedure Call (RPC). Make a call to a service that runs remotely. Here are some examples:
1. Single system
Our traditional Web system, the whole system is running on a single server, for services (such as: placing orders, payment, query, etc.) call, are called locally (or services are written locally)
2.RPC
Remote procedure calls, in plain English, invoke services written on a remote server instead of writing them locally. This has many advantages, such as the fact that a single service can fail without causing the entire system to crash (as opposed to a traditional single server). Of course, with RPC frameworks such as Dubbo, intermediate data processing is no longer a concern.
Second, the Dubbo + Zookeeper
First of all, let’s take a look at this general picture of Dubbo.
- Provider, that’s where we write our services, and Container, that’s our Spring Container.
- The Registry is responsible for registering information about the Provider service Provider for use by consumers. In fact, just like an intermediary, we can also use dubbo direct connection (generally not), so that consumers can directly find the provider (need to configure) to use the service (no middleman to earn price difference). Zookeeper is officially recommended as the registration center.
- Consumer (service Consumer), gets the required service from the registry and invokes it based on the provider information it provides.
- Monitor, which monitors consumers and providers.
Learn about the advantages of Dubbo (high availability) : 1. Zookeeper (registry) outage handling. The registry is unavailable, and the service consumer uses the service provider information held in the cache to connect and invoke the service if it has been connected before. 2. Load balancing policies are implemented based on weights. Of course, there are other load balancing strategies. 3. Service degradation, that is, when a certain service needs to occupy a large number of resources of the server, we can cancel some irrelevant services (for example, return null value, simple processing will return, etc.) 4. Service fault tolerance, which means that in the case of system processing problems, we can return null values directly. Fault tolerance is allowing mistakes to happen.
Three, use
1. Use the zookeeper
Zookeeper – 3.6.2 download After the decompression, go to the conf folder, copy and paste a copy of zoo_sample. CFG, and rename it zoo.cfg, as shown in the following figure. Note: This file is the Configuration file of ZooKeeper. Use the default file
Run /bin/zkserver.cmdAfter running, the visible port is 2181:
2. The use of dubbo
Dubbo addressAfter downloading, open dubo-admin using IDEA directly. After loading, run dubo-admin directly. Enter ** in browserhttp://localhost:7001/**, enter account root, password root, you can see our Dubbo monitoring center Many blogs have been written about springboot and Dubbo’s integration with ZooKeeper, which I won’t go into here.