Skip to content
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

fix(balancer) use a FIFO for eventual consistency updates #6833

Merged
merged 1 commit into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
362 changes: 182 additions & 180 deletions kong/runloop/balancer.lua

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions kong/runloop/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,9 @@ local function register_events()
local operation = data.operation
local upstream = data.entity

singletons.core_cache:invalidate_local("balancer:upstreams")
singletons.core_cache:invalidate_local("balancer:upstreams:" .. upstream.id)

-- => to balancer update
balancer.on_upstream_event(operation, upstream)
end, "balancer", "upstreams")
Expand Down
145 changes: 112 additions & 33 deletions spec/02-integration/05-proxy/10-balancer/01-healthchecks_spec.lua

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ for _, strategy in helpers.each_strategy() do
})

assert(bp.routes:insert({
hosts = { "least1.com" },
hosts = { "least1.test" },
protocols = { "http" },
service = bp.services:insert({
protocol = "http",
Expand Down Expand Up @@ -91,6 +91,18 @@ for _, strategy in helpers.each_strategy() do
before_each(function()
proxy_client = helpers.proxy_client()
admin_client = helpers.admin_client()
-- wait until helper servers are alive
helpers.wait_until(function()
local client = helpers.proxy_client()
local res = assert(client:send({
method = "GET",
path = "/leastconnections",
headers = {
["Host"] = "least1.test"
},
}))
return res.status == 200
end, 10)
end)

after_each(function ()
Expand All @@ -103,7 +115,7 @@ for _, strategy in helpers.each_strategy() do
end)

it("balances by least-connections", function()
local thread_max = 100 -- maximum number of threads to use
local thread_max = 50 -- maximum number of threads to use
local done = false
local results = {}
local threads = {}
Expand All @@ -115,7 +127,7 @@ for _, strategy in helpers.each_strategy() do
method = "GET",
path = "/leastconnections",
headers = {
["Host"] = "least1.com"
["Host"] = "least1.test"
},
}))
assert(res.status == 200)
Expand Down
Loading