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

Add TokenAwareLatencyHostPolicy #9

Merged
merged 1 commit into from
Feb 5, 2021
Merged

Add TokenAwareLatencyHostPolicy #9

merged 1 commit into from
Feb 5, 2021

Conversation

martin-sucha
Copy link
Collaborator

@martin-sucha martin-sucha commented Feb 3, 2021

This policy should better handle network issues where latency of some
subset of nodes is worse (e.g. when packets are dropped and the data
needs to be retransmitted).

@martin-sucha martin-sucha force-pushed the ms/tokenawarebandit branch 2 times, most recently from bfb483b to 2b6f1eb Compare February 3, 2021 10:58
@martin-sucha
Copy link
Collaborator Author

I've used RWLock while developing this, but tokenAwareHostPolicy uses lock-free reads of hosts/ring etc. It's possible we'll need to change this policy to do something similar for performance reasons (we'll see once we test it), but we probably can't avoid locking the individual hosts.

tokenawarebandit.go Outdated Show resolved Hide resolved
tokenawarebandit.go Outdated Show resolved Hide resolved
tokenawarebandit.go Outdated Show resolved Hide resolved
tokenawarebandit.go Outdated Show resolved Hide resolved
tokenawarebandit.go Outdated Show resolved Hide resolved
tokenawarebandit.go Outdated Show resolved Hide resolved
tokenawarebandit_test.go Outdated Show resolved Hide resolved
tokenawarebandit_test.go Outdated Show resolved Hide resolved
tokenawarebandit.go Outdated Show resolved Hide resolved
tokenawarebandit_test.go Outdated Show resolved Hide resolved
tokenawarebandit.go Outdated Show resolved Hide resolved
tokenawarebandit.go Outdated Show resolved Hide resolved
tokenawarebandit.go Outdated Show resolved Hide resolved
tokenawarebandit.go Outdated Show resolved Hide resolved
tokenawarebandit.go Outdated Show resolved Hide resolved
tokenawarebandit.go Outdated Show resolved Hide resolved
tokenawarebandit.go Outdated Show resolved Hide resolved
tokenawarebandit.go Outdated Show resolved Hide resolved
@mrVanboy
Copy link

mrVanboy commented Feb 3, 2021

And one last thing: could we plz organize types and their methods to be close or in a pattern:

  1. Type A definition
  2. Type A constructors
  3. Method of the type A
  4. Type B definition
  5. ...

@martin-sucha
Copy link
Collaborator Author

Okay, regorganized the file a little bit.

tokenawarebandit.go Outdated Show resolved Hide resolved
tokenawarebandit.go Outdated Show resolved Hide resolved
tokenawarebandit.go Outdated Show resolved Hide resolved
tokenawarebandit.go Outdated Show resolved Hide resolved
tokenawarebandit.go Outdated Show resolved Hide resolved
tokenawarebandit.go Outdated Show resolved Hide resolved
tokenawarebandit.go Outdated Show resolved Hide resolved
tokenawarebandit.go Outdated Show resolved Hide resolved
tokenawarebandit.go Outdated Show resolved Hide resolved
@mrVanboy
Copy link

mrVanboy commented Feb 5, 2021

Looks almost perfect! We only need to squash commits and change the commit description to reflect the new naming :) Do we want to let it run e.g. on canary over the weekend?

This policy should better handle network issues where latency of some
subset of nodes is worse (e.g. when packets are dropped and the data
needs to be retransmitted). Tracking latency allows us to detect this
case and switch to different replicas instead.

This commit introduces dependencies on github.com/klauspost/cpuid/v2
and golang.org/x/sys, so that we can use per-CPU data structures for
recording latency. This is necessary to avoid lock contention as
many queries need to write latency data to the same hosts.

Co-authored-by: Matouš Dzivjak <matous.dzivjak@kiwi.com>
Co-authored-by: Ivan Boyarkin <ivan.boyarkin@kiwi.com>
@martin-sucha
Copy link
Collaborator Author

Squashed and updated docs for TokenAwareLatencyHostPolicyOptions, TokenAwareLatencyHostPolicy and NewTokenAwareLatencyHostPolicy.

@mrVanboy mrVanboy changed the title Add TokenAwareBanditHostPolicy Add TokenAwareLatencyHostPolicy Feb 5, 2021
@mrVanboy mrVanboy merged commit 577f377 into master Feb 5, 2021
@mrVanboy mrVanboy deleted the ms/tokenawarebandit branch February 5, 2021 13:01
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.

3 participants