Single-Socket Channel

Maintain the order of the requests sent to a server by using a single TCP connection

Problem

When using Leader and Followers, we need to ensure that messages between the leader and each follower are kept in order, with a retry mechanism for any lost messages. We need to do this while keeping the cost of new connections low, so that opening connections doesn't increase the system's latency.

Solution

Fortunately, the long-used and widely available TCP protocol provides all these necessary characteristics. We can get what we need by ensuring all communication between a follower and its leader goes through a single-socket channel. The follower then serializes the updates from the leader using a Singular Update Queue.

for more details go to Chapter 30 of the online ebook at oreilly.com

This pattern is part of Patterns of Distributed Systems

23 November 2023