【WEEK15】 【DAY4】Dubbo and Zookeeper Integration Part 1【English Version】

2024.6.6 Thursday

18.Dubbo and Zookeeper Integration

18.1.Distributed Theory

Insert image description here
Insert image description here

18.1.1.What is a Distributed System?

18.1.1.1.According to the book “Principles and Paradigms of Distributed Systems,” a distributed system is defined as: “A distributed system is a collection of independent computers that appears to its users as a single coherent system.”
18.1.1.2.A distributed system is a system composed of a group of computer nodes that communicate via a network and coordinate to complete a common task. The emergence of distributed systems is to accomplish computing and storage tasks that a single computer cannot handle using inexpensive, ordinary machines. The goal is to use more machines to process more data.
18.1.1.2.1.A distributed system is a software system built on a network.
18.1.1.2.2.It is important to note that we should only consider a distributed system when a single node’s processing power cannot meet the growing computing and storage demands, when hardware upgrades (adding memory, adding disks, using better CPUs) become too costly, and when applications cannot be further optimized. Because distributed systems aim to solve the same problems as single-machine systems, the multiple-node and network communication topology of distributed systems introduces many issues not present in single-machine systems. To solve these problems, more mechanisms and protocols are introduced, bringing even more challenges.

18.1.2.Dubbo Documentation

Official Website: Apache Dubbo
With the development of the internet, the scale of web applications is continuously expanding. Conventional vertical application architectures are no longer sufficient, and distributed service architectures and mobile computing architectures are imperative. A governance system is urgently needed to ensure orderly evolution of the architecture.
The Dubbo official documentation contains the following diagram:
Insert image description here

18.1.3.Single Application Architecture

18.1.3.1.When website traffic is low, a single application can be deployed with all functions integrated to reduce deployment nodes and costs. At this stage, the data access framework (ORM) that simplifies CRUD operations is key.
Insert image description here
This is suitable for small websites and small management systems where all functions are deployed in a single unit, making it simple and easy to use.
18.1.3.2.Disadvantages:
18.1.3.2.1.Performance scalability is challenging.
18.1.3.2.2.Coordination issues in development.
18.1.3.2.3.Difficult to upgrade and maintain.

18.1.4.Vertical Application Architecture

18.1.4.1.As traffic gradually increases, the speed-up from adding more machines to a single application diminishes. Splitting the application into several unrelated applications can improve efficiency. At this stage, the web framework (MVC) that accelerates front-end page development is key.
Insert image description here
18.1.4.2.By splitting the business, each module can be deployed independently, reducing maintenance and deployment difficulties, making team management easier, and enhancing targeted performance scalability.
18.1.4.3.Disadvantages: Shared modules cannot be reused, leading to developmental waste.

18.1.5.Distributed Service Architecture

As vertical applications increase, interaction between applications becomes inevitable. Extracting core business functions into independent services gradually forms a stable service center, allowing front-end applications to respond more quickly to changing market demands. At this stage, the distributed service framework (RPC) that improves business reuse and integration is key.
Insert image description here

18.1.6.Flow Computing Architecture

As services increase, capacity assessment and the problem of small service resource waste become apparent. At this point, a scheduling center is needed to manage cluster capacity in real-time based on access pressure, improving cluster utilization. At this stage, the resource scheduling and governance center (SOA) [Service Oriented Architecture] that improves machine utilization is key.
Insert image description here

18.2.What is RPC?

18.2.1.RPC【Remote Procedure Call】is a communication method between processes. It is a concept rather than a specification. It allows a program to call a procedure or function in another address space (usually on another machine on a shared network) without the programmer explicitly coding the details of the remote call. That is, programmers write essentially the same calling code regardless of whether the function is local or remote.
18.2.2.In other words, two servers A and B, where an application is deployed on server A, need to call a function/method provided by an application on server B. Since they are not in the same memory space, a direct call is not possible, requiring the network to express the call semantics and convey the call data. Why use RPC? Because the requirements cannot be met within a single process or even a single computer through local calls, such as communication between different systems or even different organizations. When computing needs to scale horizontally, applications need to be deployed in a cluster of multiple machines. RPC aims to call remote functions as if they were local functions;
18.2.3.Reference explanation: https://www.jianshu.com/p/2accc2840a1b
18.2.4.Basic Principles of RPC
Insert image description here

18.2.5.Steps Analysis
Insert image description here

Two core modules of RPC: Communication (transport: http/RPC), serialization (facilitating data transmission).

18.3.Test Environment Setup

18.3.1.Dubbo

18.3.1.1.Introduction

Apache Dubbo |ˈdʌbəʊ| is a high-performance, lightweight open-source Java RPC framework that provides three core capabilities: interface-oriented remote method invocation, intelligent fault tolerance and load balancing, and service automatic registration and discovery.

18.3.1.2.Dubbo Official Website

http://dubbo.apache.org/zh-cn/index.html
18.3.1.2.1.Learn about Dubbo’s features.
18.3.1.2.2.Check official documentation.

18.3.1.3.Basic Concepts of Dubbo

Insert image description here

Service Provider (Provider): The service provider that exposes services. When the service provider starts, it registers its services with the registry center.

Service Consumer (Consumer): The service consumer that calls remote services. When the service consumer starts, it subscribes to the services it needs from the registry center. The service consumer selects a provider to call from the list of provider addresses based on a soft load balancing algorithm. If the call fails, it selects another provider to call.

Registry Center (Registry): The registry center returns the list of provider addresses to the consumer. If there are changes, the registry center pushes the change data to the consumer based on a long connection.

Monitoring Center (Monitor): The service consumers and providers accumulate the number of calls and the call time in memory, and periodically send the statistical data to the monitoring center every minute.

Call Relationship Explanation

  • The service container is responsible for starting, loading, and running the service provider.
  • When the service provider starts, it registers its services with the registry center.
  • When the service consumer starts, it subscribes to the services it needs from the registry center.
  • The registry center returns the list of provider addresses to the consumer. If there are changes, the registry center pushes the change data to the consumer based on a long connection.
  • The service consumer selects a provider to call from the list of provider addresses based on a soft load balancing algorithm. If the call fails, it selects another provider to call.
  • The service consumers and providers accumulate the number of calls and the call time in memory, and periodically send the statistical data to the monitoring center every minute.
    Insert image description here

18.3.2.Dubbo Environment Setup

18.3.2.1. Click into the official Dubbo documentation, recommending us to use the Zookeeper registry (older version of the webpage)
18.3.2.2. What is Zookeeper? Check: https://zookeeper.apache.org/

18.3.3.Installing Zookeeper on Windows

Reference link:
https://blog.csdn.net/qq_41929714/article/details/127581270

18.3.3.1. Download Zookeeper

https://archive.apache.org/dist/zookeeper/zookeeper-3.4.14/
Insert image description here
Unzip Zookeeper after downloading

18.3.3.2. Run /bin/zkServer.cmd. The first run (double-click to run) will report an error because there is no zoo.cfg configuration file

Insert image description here

18.3.3.3. Solution for flash quitting when double-clicking zkServer.cmd file:

Right-click the file and select “Edit,”
Insert image description here

Add the “pause” statement, Insert image description here

to prevent immediate exit on error.
Now, double-click the zkServer.cmd file again to see the error:
Insert image description here
Insert image description here
Insert image description here
View the zoo.cfg file and add some comments:
Insert image description here
Restart Zookeeper (double-click zkServer.cmd again):
Insert image description here
Insert image description here

Use zkCli.cmd for testing (double-click zkCli.cmd):
Insert image description here
It started successfully.

18.3.3.4. Further testing using zkCli.cmd

18.3.3.4.1. ls /: List all nodes saved under the Zookeeper root
Insert image description here

18.3.3.4.2. create -e /Zzz 12345: Create a Zzz node with the value 12345
Insert image description here
18.3.3.4.3. get /Zzz: Get the value of the /Zzz node
Insert image description here

18.3.3.4.4. Check the node again
Insert image description here

18.3.3.5. Other interesting operations

Click the file navigation bar, add "cmd " at the very front and press Enter, as shown in the figure below:
Insert image description here

This will pop up the command line:
Insert image description here

  • 11
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值