Skip to content

ReadMode: introduce AutoFollowerRead mechanism by adding a new ReadMode == PreferLeader#671

Merged
disksing merged 38 commits intotikv:masterfrom
LykxSassinator:auto_redirect_flows
Feb 7, 2023
Merged

ReadMode: introduce AutoFollowerRead mechanism by adding a new ReadMode == PreferLeader#671
disksing merged 38 commits intotikv:masterfrom
LykxSassinator:auto_redirect_flows

Conversation

@LykxSassinator
Copy link
Contributor

@LykxSassinator LykxSassinator commented Jan 17, 2023

Description

Introduce AutoFollowerRead mechanism to improve the Read availability on Read workloads when setting with ReadMode == PreferLeader. Here, a new read mode PreferLeader has been introduced for enabling this mechanism.

Close #670.

Signed-off-by: lucasliang nkcs_lykx@hotmail.com

Signed-off-by: Lucasliang <nkcs_lykx@hotmail.com>
Signed-off-by: Lucasliang <nkcs_lykx@hotmail.com>
Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
Signed-off-by: Lucasliang <nkcs_lykx@hotmail.com>
Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
Signed-off-by: Lucasliang <nkcs_lykx@hotmail.com>
Signed-off-by: Lucasliang <nkcs_lykx@hotmail.com>
Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
…ose AufoFollowerRead feature.

Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
…ed into "replica_mode=leader-and-follower".

Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
Signed-off-by: Lucasliang <nkcs_lykx@hotmail.com>
…der ReplicaReadMixed mode.

Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
…es, making it meet the uniform distribution.

Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
Signed-off-by: Lucasliang <nkcs_lykx@hotmail.com>
Signed-off-by: Lucasliang <nkcs_lykx@hotmail.com>
Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
@LykxSassinator LykxSassinator marked this pull request as draft January 17, 2023 08:09
…errors.

Signed-off-by: Lucasliang <nkcs_lykx@hotmail.com>
@LykxSassinator LykxSassinator marked this pull request as ready for review January 17, 2023 08:59
@LykxSassinator LykxSassinator marked this pull request as draft January 18, 2023 09:05
Signed-off-by: Lucasliang <nkcs_lykx@hotmail.com>
@LykxSassinator LykxSassinator marked this pull request as ready for review January 28, 2023 03:26
@LykxSassinator
Copy link
Contributor Author

@tonyxuqqi PTAL,thx

@disksing disksing requested a review from tonyxuqqi January 28, 2023 07:20
@disksing
Copy link
Collaborator

disksing commented Jan 28, 2023

I wonder If the load of different stores is different (for example, some stores are all point get requests, while others are full table scans), then the method of determining store slow may not be accurate.

@LykxSassinator
Copy link
Contributor Author

I wonder If the load of different stores is different (for example, some stores are all point get requests, while others are full table scans), then the method of determining store slow may not be accurate.

Thx for your comments.
What u've pointed about the influence of different workloads has been considered in the design of the detection algorithm.

Design in brief introduction

One store in TiKV clusters may be slow because of network delays or IO delays on disk. Currently, we cannot have a very concise method to aggregate all informations into the Client and make the determination on which store is slow.
So, we use a measurement, so-called Slow Score, to represent the severity of slow on each store. And only when the Slow Score exceed the threshold(80 in current implementation), will the corresponding store be marked as SLOW. Then, the read flows will be redirected to other nodes.

And about the calculation of Slow Score, we introduce two dimensions to determine it on each store:

  • Requests in one timing tick. This dimension can be regarded as QPS on each store.
  • Average timecost on each request in one timing tick. This dimension is used to detect whether the relative store is busy on processing requests.

And as we known, if one store is slow, its Requests will keep decreasing gradually, but Average timecost will keep ascending.
image

So, we just introduce an appropriate algorithm(just like Sliding window) to combine these two factors and convert them to Slow Score, for representing the business of each node. That is:

  • Slow Score focus the severity of slowness on each store, and each store has its own counting statistics for calculating Slow Score.
  • Slow Score of one store will gradually ascend if this store is gradually slow on processing requests. And this store will be marked as SLOW if Slow Score exceed the threshold.

Of course, about the point on:

store slow may not be accurate.

Slow Score can be more accurate if we make the statistics divided by the type of commands, which can be reviewed in later generation of this algorithm. We just wanna introduce an appropriate and simple way, for less costs of resources, to optimize the replica_read_mode == leader_and_follower mode.

@disksing
Copy link
Collaborator

@LykxSassinator Thank you for the clarification.

… a new mode `prefer-leader`.

Signed-off-by: Lucasliang <nkcs_lykx@hotmail.com>
@LykxSassinator LykxSassinator changed the title ReadMode: introduce AutoFollowerRead mechanism to enhance availabilities on ReadMode == LeaderAndFollower ReadMode: introduce AutoFollowerRead mechanism by adding a new ReadMode == PreferLeader Jan 31, 2023
Signed-off-by: Lucasliang <nkcs_lykx@hotmail.com>
Signed-off-by: Lucasliang <nkcs_lykx@hotmail.com>
Signed-off-by: Lucasliang <nkcs_lykx@hotmail.com>
@LykxSassinator
Copy link
Contributor Author

cc @disksing PTAL, thx.

@disksing disksing merged commit bce56a5 into tikv:master Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ReadMode: support filtering out slow nodes to improve availabilities on Read workloads

3 participants