Corresponding to the message sending channel, the message sent requires a receiving end to receive the message, which is channelreceiver. The receiving side is responsible for receiving messages sent by other nodes from the message send channel, in fact each node has a channelsender and channelreceiver, Channelsender sends a message to the channelreceiver of the other node . The essence is that each node exposes one port as the server listener client, and each node acts as a server for the client to connect to the other nodes, so channelsender is a collection of clients. The Channelreceiver acts as a service side.
During the cluster message replication process, each nodeChannelreceiveris responsible for receiving messages from other nodes, assuming aNcluster of nodes, in general the case of eachChannelreceivercorrespondingn-1Connection, because the communication connections between the clusters are long connections, long connections help to improve communication efficiency, such as4nodes of a cluster,Node1of theChannelreceiverthe number of client connections is3, respectively isNode2,Node3,Node4three nodes initiated as a clientSocketconnection. The data generated by these three nodes is synchronized through this channel to aNode1node, in the same way,Node2of theChannelreceiverhaveNode1,Node3,Node4Client connection, the data generated by these three nodes is also synchronized to theNode2node. Node3,Node4also has three client connections. To improve processing efficiency, use theNIOprocess the model.
In addition, the re-receive operation in order to optimize performance to take a number of measures, such as the introduction of task pool, that is, the receiving task is defined in advance to put in memory, receive can be directly used without the instantiation, for example, a number of messages to be processed, i.e. using nio The pattern reads the message into the buffer and processes the entire buffer directly, it may contain several messages, and the network IO needs to be optimized in more places and means,tribes Have done a lot of optimization work.
Students who like Java can make a friend:
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Message receive channel for the cluster