Thursday, 21 February 2019

Communication and Networking Concepts and Architectures



3 Types of Communication Protcols

UDP, Multicast and TCP

UDP - Unreliable, fire and forget, no guarantee of any delivery

Multicast - Fastest possible protocol especially for a cluster node, but is also unreliable

TCP - Most reliable and hence the slowest


Communication Protocol Fundamentals

Discovery - When nodes join a single View object should be formed to display all joined nodes or even the entire network

Sequencing - Every message should have a sequence number

Fragmentation - Every medium would have a MTU so fragments should meet this config


JGroups - JGroups is a custom java based protocol library that combines the best of Multicast Java API with the various protocol features of TCP through configurable Java classes.

A JGroups cluster of nodes forms the basic single Data Center cluster of nodes for a J2EE Web application. Multiple such clusters connected through a unique coordinator in each DC forms the actual multisite cluster.

A Stomp client in JGroups terminology - is a browser TCP client that connects to one of the nodes of such a cluster. While this node talks to multiple Cient browsers through TCP, it has one Multicast node with the JGroups Multicast node to establish a no single point of failure cluster and uses it for data replication across all the multicast nodes in one DC.

The advanced features that JGroups API provides are that of NAKACK and Multicast Flow Control.
Negative Acks are more efficient as each message is not Acked thereby reducing traffic and not having to do double the messaging. Negative Ack works together with Suquencer - if the receiver receives a jump in the sequence number it requests the sender to send the missing sequence numbers from the buffer.

Flow Control requires each JGroups node to maintain a map of each node and it's threshold value. As soon as the slowest processor node reaches it's threshold message size it sends a token to the senders to hold on to sending further messages, the slowest processor node then processes all the messages and then sends a replenishment token asking the senders to resume sending messages.
This allows no single sender to choke the network.

The following diagrams depict a basic Networking Architecture and a complex Cluster based on JGroups:



Networking Architecture - WebApp Cluster With DB Cluster


WebApp Cluster with Each WebApp Server Clsuter Node having own DB node and other would be with Single DB Node of a Multisite DB Cluster

With the Second one i.e. with Single DB Node you would need locking mechanism in WebApp so no 2 users mess with single record

Challenge with 1st approach would be - in case of a relational db structure - maintaining transactional replication across db nodes would need manual sync up in case of failures. Or loss of data in case of issues.




A pictorial depiction of the above is pending to be published.




Client Server Working - Internal Logic Depiction