Skip to content

Extend mirrord-protocol to allow concurrent send/receive #3524

@Razz4780

Description

@Razz4780

EDIT: chunking delayed until we move to a simpler protocol negotiation mechanism. Until then, we settle on concurrent send/receive of whole messages

mirrord-protocol is our bincode-based protocol used for network communication between mirrord processes (e.g. mirrord-intproxy and mirrord-agent). It always utilizes a single TCP connection, and messages are always processed in a first-come first-served manner. This behavior causes issues when mirrord components compete for the connection. E.g. outgoing traffic feature is used to enable communication with remote databases, and often produces a lot of traffic. This traffic can significantly increase latency for other components, e.g. ping pong mechanism, which leads to timeouts and failures.

The idea here is to implement fair sharing of a single mirrord-protocol connection between multiple components, so that messages can be transferred concurrently, and each component has an equal share of total network bandwidth.

Essentially:

  1. Each ClientMessage and DaemonMessage variant represents a separate message group.
  2. Within each message group, messages are processed sequentially.
  3. Groups are processed concurrently.

For instance, this could be implemented as follows (but more clever solutions are always welcome):

  1. Messages to send are chunked and added to their group's queue
  2. p's receive buffer
  3. When group's receive buffNext chunk to send is selected from the head of a random group's queue
  4. Received chunks are added to their grouer is ready, complete message is received

When implementing, mind that:

  1. mirrord-protocol must remain backwards compatible. We normally use ClientMessage::SwitchProtocolVersion request to negotiate mirrord-protocol version with the peer. The negotiated version determines which messages can be sent over the wire.
  2. This extension should not introduce any significant time or memory overhead.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions