mirror of
https://github.com/benbusby/farside.git
synced 2025-04-29 23:20:03 +00:00
Prevent same instance from being selected twice in a row
Introduces a new db key "<service>-previous" to track which instance was last selected for a particular service. This allows for filtering the list of available instances to exclude the instance that was last picked, to ensure a (slightly) more even distribution of traffic. There's still the possiblity of the following scenario, however: :service instances > 2 /:service request #1 -> instance #1 /:service request #2 -> instance #2 /:service request #3 -> instance #1 /:service request #4 -> instance #2 where there are many ignored instances for a particular service. One possible solution would be to implement the "<service>-previous" value to be a list, rather than a single value, and push to that list until only one element is left in the original "instance" array after filtering, and then delete the "<service>-previous" key.
This commit is contained in:
parent
71fb89e028
commit
8ee4f308a4
4 changed files with 45 additions and 8 deletions
|
@ -2,8 +2,9 @@ import Config
|
|||
|
||||
config :farside,
|
||||
redis_conn: "redis://localhost:6379",
|
||||
fallback_str: "-fallback",
|
||||
update_file: ".update-results",
|
||||
service_prefix: "service-",
|
||||
fallback_suffix: "-fallback",
|
||||
previous_suffix: "-previous",
|
||||
services_json: "services.json",
|
||||
index: "index.eex"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue