Skip to content

Commit

Permalink
fix(balancer) use a FIFO for eventual consistency updates
Browse files Browse the repository at this point in the history
* When using eventual worker consistency, instead of trying to
  synchronize all workers using a shared dictionary, share the events
  and let each worker deal with its updates.
* Fix several IPv6 issues in balancer tests.
* Balancer stress tests file was renamed, so the tests must be ran on
  demand from now on, as they take a long time to run and most of them
  seem to be flaky on CI environment.
  • Loading branch information
locao committed Mar 3, 2021
1 parent e97fef0 commit 2f2bb9f
Show file tree
Hide file tree
Showing 8 changed files with 807 additions and 218 deletions.
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

0 comments on commit 2f2bb9f

Please sign in to comment.