Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Optimise queueing of inbound replication commands #7861

Merged
merged 5 commits into from
Jul 16, 2020

Conversation

richvdh
Copy link
Member

@richvdh richvdh commented Jul 15, 2020

When we get behind on replication, we tend to stack up background processes behind a linearizer. Bg processes are heavy (particularly with respect to prometheus metrics) and linearizers aren't terribly efficient once the queue gets long either.

A better approach is to maintain a queue of requests to be processed, and nominate a single process to work its way through the queue.

Fixes: #7444

When we get behind on replication, we tend to stack up background processes
behind a linearizer. Bg processes are heavy (particularly with respect to
prometheus metrics) and linearizers aren't terribly efficient once the queue
gets long either.

A better approach is to maintain a queue of requests to be processed, and
nominate a single process to work its way through the queue.

Fixes: #7444
@richvdh
Copy link
Member Author

richvdh commented Jul 15, 2020

(this is best reviewed with whitespace changes hidden)

@richvdh richvdh requested a review from a team July 15, 2020 19:29
@richvdh richvdh force-pushed the rav/optimise_replication_queue branch from 1bc4e93 to 1cc6c93 Compare July 15, 2020 19:30
@richvdh richvdh force-pushed the rav/optimise_replication_queue branch from 1cc6c93 to a507496 Compare July 15, 2020 19:31
... because stock `typing` doesn't have it in Python 3.5.
@richvdh richvdh requested review from a team and removed request for a team July 16, 2020 12:08
Comment on lines 148 to 150
stream_name: Deque[
Tuple[Union[RdataCommand, PositionCommand], AbstractConnection]
]()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, from PEP 484:

It is not recommended to use the subscripted class (e.g. Node[int]) directly in an expression -- using a type alias (e.g. IntNode = Node[int]) instead is preferred. (First, creating the subscripted class, e.g. Node[int], has a runtime cost. Second, using a type alias is more readable.)

Since this is instantiating the type a few times, and the type is going across 3 lines, probably worth aliasing it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great suggestion, thanks.

@erikjohnston erikjohnston merged commit e530006 into develop Jul 16, 2020
@erikjohnston erikjohnston deleted the rav/optimise_replication_queue branch July 16, 2020 14:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

consider handling incoming replication queues in a more efficient way
3 participants