Hyperledger Fabric tutorial (15)-Kafka-based Order service combat

 

1. Order service based on Kafka

Distributed sorting service

The Kafka-based sorting service uses Kafka as a transaction message queue to achieve high-throughput data distribution.

Each channel corresponds to a topic of Kafka .

 

The ordering service node plays different roles in different stages.

 

1. Receiving transaction stage:

The ordering service node acts as a Kafka producer and forwards the transaction to the topic of the corresponding channel after receiving the transaction.

 

2. Message processing stage:

Service node acts as a sort of Kafka is a consumer (consumer), real-time monitoring messages for subsequent processing to generate a block or split transaction messages.

 

Second, the best practice of order based on Kafka

 

1. Number of nodes of Kafka and Zookeeper 

The number of nodes in Kafka is K 

The number of Zookeeper nodes is Z

K requires at least 4 nodes

Only after one node goes down can continue to submit transactions, sort and create new channels.

 

Z can choose 3, 5 or 7 nodes.

Choosing an odd number of nodes can avoid split-brain. 1 node will have a single point problem, and more than 7 nodes will be too much.

 

Three, the yaml file required for practice

docker-compose-cli.yaml

  

docker-compose-base.yaml

 

peer-base.yaml

 

docker-compose-couch.yaml

 

dc-orderer-kafka-base.yml

 

dc-orderer-kafka.yml

 

 

 

Fourth, data persistence

container

Path in the container

Host path

peer

/ var / hyperledger / production

./p0o1

orderer

/ var / hyperledger / production / orderer

./orderer0

kafka

/tmp/kafka-logs

./k0

couchdb

/opt/couchdb/data

./c0

 

 

Five, Kafka configuration

min.insync.relicas = 2 (M)

At least the number of written copies, and the number of written copies of a message is not less than this number to confirm that the writing is successful.

The larger the value, the more reliable the system, the smaller the higher the performance.

The reason for setting 2 here is to avoid a single point of failure.

 

default.relication.factor = 3 (N)

The number of copies saved when creating a theme. When creating a channel, at least N nodes must synchronize data to create a successful one.

The value of N needs to satisfy 1<M<N<K, N<K because K needs to have a node redundancy.

 

unclean.leader.clection.enable = false

Whether to allow nodes not in the replica synchronization set to elect as the master node, the master node is responsible for reading and writing messages.

A message is submitted successfully only when all nodes in the replica synchronization set are synchronized.

If nodes not in the synchronization set are allowed to elect as the master node, there is a risk of data loss.

 

 

 

 

 

 

 

 

 

Guess you like

Origin blog.csdn.net/u013288190/article/details/112396919