Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
87360ee3
Commit
87360ee3
authored
Mar 01, 2018
by
cdjin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wrr algorithm enhancement
parent
d894cba7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
4 deletions
+5
-4
weighted_round_robin_load_balancer.cpp
src/brpc/policy/weighted_round_robin_load_balancer.cpp
+4
-3
weighted_round_robin_load_balancer.h
src/brpc/policy/weighted_round_robin_load_balancer.h
+1
-1
No files found.
src/brpc/policy/weighted_round_robin_load_balancer.cpp
View file @
87360ee3
...
...
@@ -139,7 +139,7 @@ int WeightedRoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut*
tls
.
ResetRemainServer
();
}
for
(
uint32_t
i
=
0
;
i
!=
tls
.
stride
;
++
i
)
{
int64_t
best
=
GetBestServer
(
s
->
server_list
,
tls
,
tls
.
stride
);
int64_t
best
=
GetBestServer
(
s
->
server_list
,
tls
);
if
(
!
ExcludedServers
::
IsExcluded
(
in
.
excluded
,
best
)
&&
Socket
::
Address
(
best
,
out
->
ptr
)
==
0
&&
!
(
*
out
->
ptr
)
->
IsLogOff
())
{
...
...
@@ -150,10 +150,11 @@ int WeightedRoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut*
}
int64_t
WeightedRoundRobinLoadBalancer
::
GetBestServer
(
const
std
::
vector
<
std
::
pair
<
SocketId
,
int
>>&
server_list
,
TLS
&
tls
,
uint32_t
stride
)
{
const
std
::
vector
<
std
::
pair
<
SocketId
,
int
>>&
server_list
,
TLS
&
tls
)
{
uint32_t
comp_weight
=
0
;
int64_t
final_server
=
-
1
;
uint32_t
stride
=
tls
.
stride
;
while
(
stride
>
0
)
{
if
(
tls
.
HasRemainServer
())
{
uint32_t
remain_weight
=
tls
.
remain_server
.
second
;
...
...
src/brpc/policy/weighted_round_robin_load_balancer.h
View file @
87360ee3
...
...
@@ -87,7 +87,7 @@ private:
static
size_t
BatchRemove
(
Servers
&
bg
,
const
std
::
vector
<
ServerId
>&
servers
);
static
int64_t
GetBestServer
(
const
std
::
vector
<
std
::
pair
<
SocketId
,
int
>>&
server_list
,
TLS
&
tls
,
uint32_t
stride
);
TLS
&
tls
);
// Get a reasonable stride according to weights configured of servers.
static
uint32_t
GetStride
(
const
uint32_t
weight_sum
,
const
uint32_t
num
);
static
void
TryToGetFinalServer
(
const
TLS
&
tls
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment