-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make heavy loaded optimization configurable #114
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,24 @@ type ClusterConfig struct { | |
// Default: 128 for older CQL versions | ||
MaxRequestsPerConn int | ||
|
||
// Threshold for the number of inflight requests per connection | ||
// after which the connection is considered as heavy loaded | ||
// Default: 512 | ||
HeavyLoadedConnectionThreshold int | ||
|
||
// When a connection is considered as heavy loaded, the driver | ||
// could switch to the least loaded connection for the same node. | ||
// The switch will happen if the other connection is at least | ||
// HeavyLoadedSwitchConnectionPercentage percentage less busy | ||
// (in terms of inflight requests). | ||
// | ||
// For the default value of 20%, if the heavy loaded connection | ||
// has 100 inflight requests, the switch will happen only if the | ||
// least busy connection has less than 80 inflight requests. | ||
// | ||
// Default: 20% | ||
HeavyLoadedSwitchConnectionPercentage int | ||
|
||
// Default consistency level. | ||
// Default: Quorum | ||
Consistency Consistency | ||
|
@@ -267,6 +285,8 @@ func NewCluster(hosts ...string) *ClusterConfig { | |
ConnectTimeout: 600 * time.Millisecond, | ||
Port: 9042, | ||
NumConns: 2, | ||
HeavyLoadedConnectionThreshold: 512, | ||
HeavyLoadedSwitchConnectionPercentage: 20, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please run gofmt on this file. It will be annoying for others contributors if gofmt keeps formatting code that they didn't modify. |
||
Consistency: Quorum, | ||
MaxPreparedStmts: defaultMaxPreparedStmts, | ||
MaxRoutingKeyInfo: 1000, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,3 +145,7 @@ func (s *IDGenerator) Clear(stream int) (inuse bool) { | |
func (s *IDGenerator) Available() int { | ||
return s.NumStreams - int(atomic.LoadInt32(&s.inuseStreams)) - 1 | ||
} | ||
|
||
func (s *IDGenerator) InUse() int { | ||
return int(atomic.LoadInt32(&s.inuseStreams)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A question from a C-guy: why did you have to create all these complications with casting like this one ( I assume that the reason you need to do all these transformations is because Am I missing something? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is due to golang |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please validate that this parameter is within valid range when the session is being created.