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

Counters & Lists landing page and doc improvements #3649

Merged
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
2 changes: 1 addition & 1 deletion examples/counterfleetautoscaler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
type: Counter # Counter based autoscaling
counter:
# Key is the name of the Counter. Required field.
key: players
key: rooms
# BufferSize is the size of a buffer of counted items that are available in the Fleet (available capacity).
# Value can be an absolute number (ex: 5) or a percentage of the Counter available capacity (ex: 5%).
# An absolute number is calculated from percentage by rounding up. Must be bigger than 0. Required field.
Expand Down
2 changes: 1 addition & 1 deletion examples/fleet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ spec:
# [FeatureFlag:CountsAndLists]
# Which gameservers in the Fleet are most important to keep around - impacts scale down logic.
# priorities:
# - type: List # Whether a Counter or a List.
# - type: Counter # Whether a Counter or a List.
# key: rooms # The name of the Counter or List.
# order: Ascending # Default is "Ascending" so smaller capacity will be removed first on down scaling.
#
Expand Down
31 changes: 31 additions & 0 deletions examples/gameserverallocation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,34 @@ spec:
mode: deathmatch
annotations:
map: garden22
# [Stage: Alpha]
# [FeatureFlag:CountsAndLists]
# `Priorities` configuration alters the order in which `GameServers` are searched for matches to the configured `selectors`.
#
# Priority of sorting is in descending importance. I.e. The position 0 `priority` entry is checked first.
#
# For `Packed` strategy sorting, this priority list will be the tie-breaker within the least utilised infrastructure, to ensure optimal
# infrastructure usage while also allowing some custom prioritisation of `GameServers`.
#
# For `Distributed` strategy sorting, the entire selection of `GameServers` will be sorted by this priority list to provide the
# order that `GameServers` will be allocated by.
# Optional.
# priorities:
markmandel marked this conversation as resolved.
Show resolved Hide resolved
# - type: Counter # Whether a Counter or a List.
# key: rooms # The name of the Counter or List.
# order: Ascending # "Ascending" lists smaller available capacity first.
# [Stage:Alpha]
# [FeatureFlag:CountsAndLists]
# Counter actions to perform during allocation. Optional.
# counters:
# rooms:
# action: Increment # Either "Increment" or "Decrement" the Counter’s Count.
# amount: 1 # Amount is the amount to increment or decrement the Count. Must be a positive integer.
# capacity: 5 # Amount to update the maximum capacity of the Counter to this number. Min 0, Max int64.
# List actions to perform during allocation. Optional.
# lists:
# players:
# addValues: # appends values to a List’s Values array. Any duplicate values will be ignored
# - x7un
# - 8inz
# capacity: 40 # Updates the maximum capacity of the Counter to this number. Min 0, Max 1000.
2 changes: 1 addition & 1 deletion examples/listfleetautoscaler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
type: List # List based autoscaling.
list:
# Key is the name of the List. Required field.
key: rooms
key: players
# BufferSize is the size of a buffer based on the List capacity that is available over the current
# aggregate List length in the Fleet (available capacity).
# It can be specified either as an absolute value (i.e. 5) or percentage format (i.e. 5%).
Expand Down
2 changes: 1 addition & 1 deletion install/helm/agones/templates/crds/fleet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ spec:
description: The name of the Counter or List. If not found on the GameServer, those GameServer with the key will have priority over those that do not.
order:
type: string
description: Ascending or Descending sort order. Default is "Ascending" so remove smaller total capacity first. "Descending" would remove larger total capacity first.
description: Ascending or Descending sort order. Default is "Ascending" so remove smaller available capacity first. "Descending" would remove larger available capacity first.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is total, not available.

// compareGameServerCapacity compares two game servers based on a CountsAndLists Priority. First
// compares by Capacity, and then compares by Count or length of the List Values if Capacity is equal.
// NOTE: This does NOT sort by available capacity.
// Returns -1 if gs1 < gs2; 1 if gs1 > gs2; 0 if gs1 == gs2; 0 if neither gamer server has the Priority.
// If only one game server has the Priority, prefer that server. I.e. nil < gsX when Priority
// Order is Descending (3, 2, 1, 0, nil), and nil > gsX when Order is Ascending (0, 1, 2, 3, nil).
func compareGameServerCapacity(p *agonesv1.Priority, gs1, gs2 *agonesv1.GameServer) int {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh interesting! I didn't expect that, I just assumed they would be the same to be honest!

I do now have some vague memories of conversations on this topic -- but I can't remember the exact reason we did this.

Something to do with how the Autoscaler works out if it can scale down or not, and matching that logic here so it aligns as close as possible, if I remember correctly?

Can you remind me again of why this works this way, so I can capture it in the docs and head off any potential confusion here.

Having two different strategies for priorities in different places might be confusing (🤔 maybe), but that being said, I always expected the CUJ for this to be more on the count/list length value and capacity to be a non-factor 🤷🏻 .

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I remember talking about it too, but can't find it in chat or meeting notes.

Since the autoscaler never removes allocated game servers, what this really does is sort the non-allocated game servers, and remove those in order of largest or smallest capacity (after sorting by packed strategy). Which I think we decided was more important than "available capacity" for non-allocated game servers.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I'm digging into the FleetAutoscaler, and I'm seeing that it's also working on available capacity (which makes sense to calculate the buffer).

func applyCounterOrListPolicy(c *autoscalingv1.CounterPolicy, l *autoscalingv1.ListPolicy,

As a result of writing the docs, and seeing the different approaches now side by side, I'm thinking we should file a ticket to change the sorting strategy for Fleet scale down to be based on available capacity, and implement it in a separate PR?

9.9 times out of 10, I expect it to be exactly the same as set capacity with a count/length tiebreaker (since I expect dynamic capacities in GameServers that are Ready to be minimal, and counts > 0 in a Ready GameServer to be even less of an occurrence) - but it means that the concepts and the documentation across all functionality align, and are easier to reconcile when working with it?

WDYT @igooch ? If you're happy, I'll file the ticket and make the change - looks like it should be relatively minimal.

Then we can also work out how we want to manage the switchover in docs 😄 but lemme know what you think.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fleet autoscaler buffer is calculated based on available capacity, the priorities are not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just chatting offline - doesn't seem like a huge concern if I go do the work. So will pause on this doc, and see if it's onerous to change the ordering strategy on Fleet scaledown, and then the documentation is much easier to write.

enum:
- Ascending
- Descending
Expand Down
2 changes: 1 addition & 1 deletion install/yaml/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ spec:
description: The name of the Counter or List. If not found on the GameServer, those GameServer with the key will have priority over those that do not.
order:
type: string
description: Ascending or Descending sort order. Default is "Ascending" so remove smaller total capacity first. "Descending" would remove larger total capacity first.
description: Ascending or Descending sort order. Default is "Ascending" so remove smaller available capacity first. "Descending" would remove larger available capacity first.
enum:
- Ascending
- Descending
Expand Down
19 changes: 14 additions & 5 deletions pkg/allocation/go/allocation.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/allocation/go/allocation.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,14 @@
"type": "object",
"$ref": "#/definitions/allocationPriority"
},
"description": "(Alpha, CountsAndLists feature flag) The first Priority on the array of Priorities is the most\nimportant for sorting. The allocator will use the first priority for sorting GameServers in the\nSelector set, and will only use any following priority for tie-breaking during sort.\nImpacts which GameServer is checked first."
"description": "[Stage: Alpha]\n[FeatureFlag:CountsAndLists]\n`Priorities` configuration alters the order in which `GameServers` are searched for matches to the configured `selectors`.\n\nPriority of sorting is in descending importance. I.e. The position 0 `priority` entry is checked first.\n\nFor `Packed` strategy sorting, this priority list will be the tie-breaker within the least utilised infrastructure, to ensure optimal\ninfrastructure usage while also allowing some custom prioritisation of `GameServers`.\n\nFor `Distributed` strategy sorting, the entire selection of `GameServers` will be sorted by this priority list to provide the\norder that `GameServers` will be allocated by."
},
"counters": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/allocationCounterAction"
},
"description": "(Alpha, CountsAndLists feature flag) Counters and Lists provide a set of actions to perform\non Counters and Lists during allocation."
"description": "[Stage: Alpha]\n[FeatureFlag:CountsAndLists]\nCounters and Lists provide a set of actions to perform\non Counters and Lists during allocation."
},
"lists": {
"type": "object",
Expand Down
7 changes: 4 additions & 3 deletions pkg/apis/agones/v1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,15 @@ func (ao *AllocationOverflow) Apply(gs *GameServer) {
}
}

// Priority is a sorting option for GameServers with Counters or Lists based on the Capacity.
// Priority is a sorting option for GameServers with Counters or Lists based on the available capacity,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use priorities in two different places in two different ways. The fleet autoscaler uses total capacity (see comment in fleet.yaml), and the game server allocation uses available capacity.

// compareGameServers compares two game servers based on a CountsAndLists Priority using available
// capacity (Capacity - Count for Counters, and Capacity - len(Values) for Lists) as the comparison.
// Returns -1 if gs1 < gs2; 1 if gs1 > gs2; 0 if gs1 == gs2; 0 if neither gamer server has the Priority.
// If only one game server has the Priority, prefer that server. I.e. nil < gsX when Priority
// Order is Descending (3, 2, 1, 0, nil), and nil > gsX when Order is Ascending (0, 1, 2, 3, nil).
func compareGameServers(p *agonesv1.Priority, gs1, gs2 *agonesv1.GameServer) int {

// i.e. the current Capacity value, minus either the Count value or List length.
type Priority struct {
// Type: Sort by a "Counter" or a "List".
Type string `json:"type"`
// Key: The name of the Counter or List. If not found on the GameServer, has no impact.
Key string `json:"key"`
// Order: Sort by "Ascending" or "Descending". "Descending" a bigger Capacity is preferred.
// "Ascending" would be smaller Capacity is preferred.
// Order: Sort by "Ascending" or "Descending". "Descending" a bigger available capacity is preferred.
// "Ascending" would be smaller available capacity is preferred.
Order string `json:"order"`
}

Expand Down
15 changes: 11 additions & 4 deletions pkg/apis/agones/v1/fleet.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,17 @@ type FleetSpec struct {
Strategy appsv1.DeploymentStrategy `json:"strategy"`
// Scheduling strategy. Defaults to "Packed".
Scheduling apis.SchedulingStrategy `json:"scheduling"`
// (Alpha, CountsAndLists feature flag) The first Priority on the array of Priorities is the most
// important for sorting. The Fleetautoscaler will use the first priority for sorting GameServers
// by total Capacity in the Fleet and acts as a tie-breaker after sorting the game servers by
// State and Strategy. Impacts scale down logic.
// [Stage: Alpha]
// [FeatureFlag:CountsAndLists]
// `Priorities` configuration alters scale down logic in Fleets based on the configured available capacity order under that key.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// `Priorities` configuration alters scale down logic in Fleets based on the configured available capacity order under that key.
// `Priorities` configuration alters scale down logic in Fleets based on the configured total capacity order under that key.

//
// Priority of sorting is in descending importance. I.e. The position 0 `priority` entry is checked first.
//
// For `Packed` strategy scale down, this priority list will be the tie-breaker within the node, to ensure optimal
// infrastructure usage while also allowing some custom prioritisation of `GameServers`.
//
// For `Distributed` strategy scale down, the entire `Fleet` will be sorted by this priority list to provide the
// order of `GameServers` to delete on scale down.
// +optional
Priorities []Priority `json:"priorities,omitempty"`
// Template the GameServer template to apply for this Fleet
Expand Down
15 changes: 11 additions & 4 deletions pkg/apis/agones/v1/gameserverset.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,17 @@ type GameServerSetSpec struct {
AllocationOverflow *AllocationOverflow `json:"allocationOverflow,omitempty"`
// Scheduling strategy. Defaults to "Packed".
Scheduling apis.SchedulingStrategy `json:"scheduling,omitempty"`
// (Alpha, CountsAndLists feature flag) The first Priority on the array of Priorities is the most
// important for sorting. The Fleetautoscaler will use the first priority for sorting GameServers
// by total Capacity in the Fleet and acts as a tie-breaker after sorting the game servers by
// State and Strategy. Impacts scale down logic.
// [Stage: Alpha]
// [FeatureFlag:CountsAndLists]
// `Priorities` configuration alters scale down logic in Fleets based on the configured available capacity order under that key.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// `Priorities` configuration alters scale down logic in Fleets based on the configured available capacity order under that key.
// `Priorities` configuration alters scale down logic in Fleets based on the configured total capacity order under that key.

//
// Priority of sorting is in descending importance. I.e. The position 0 `priority` entry is checked first.
//
// For `Packed` strategy scale down, this priority list will be the tie-breaker within the node, to ensure optimal
// infrastructure usage while also allowing some custom prioritisation of `GameServers`.
//
// For `Distributed` strategy scale down, the entire `Fleet` will be sorted by this priority list to provide the
// order of `GameServers` to delete on scale down.
// +optional
Priorities []Priority `json:"priorities,omitempty"`
// Template the GameServer template to apply for this GameServerSet
Expand Down
31 changes: 23 additions & 8 deletions pkg/apis/allocation/v1/gameserverallocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,17 @@ type GameServerAllocationSpec struct {
// This is useful for things like smoke testing of new game servers.
Preferred []GameServerSelector `json:"preferred,omitempty" hash:"ignore"`

// (Alpha, CountsAndLists feature flag) The first Priority on the array of Priorities is the most
// important for sorting. The allocator will use the first priority for sorting GameServers by
// available Capacity in the Selector set. Acts as a tie-breaker after sorting the game servers
// by State and Strategy Packed. Impacts which GameServer is checked first.
// [Stage: Alpha]
// [FeatureFlag:CountsAndLists]
// `Priorities` configuration alters the order in which `GameServers` are searched for matches to the configured `selectors`.
//
// Priority of sorting is in descending importance. I.e. The position 0 `priority` entry is checked first.
//
// For `Packed` strategy sorting, this priority list will be the tie-breaker within the least utilised infrastructure, to ensure optimal
// infrastructure usage while also allowing some custom prioritisation of `GameServers`.
//
// For `Distributed` strategy sorting, the entire selection of `GameServers` will be sorted by this priority list to provide the
// order that `GameServers` will be allocated by.
// +optional
Priorities []agonesv1.Priority `json:"priorities,omitempty"`

Expand All @@ -105,10 +112,14 @@ type GameServerAllocationSpec struct {
// You can use this to tell the server necessary session data
MetaPatch MetaPatch `json:"metadata,omitempty" hash:"ignore"`

// (Alpha, CountsAndLists feature flag) Counter actions to perform during allocation.
// [Stage: Alpha]
// [FeatureFlag:CountsAndLists]
// Counter actions to perform during allocation.
// +optional
Counters map[string]CounterAction `json:"counters,omitempty" hash:"ignore"`
// (Alpha, CountsAndLists feature flag) List actions to perform during allocation.
// [Stage: Alpha]
// [FeatureFlag:CountsAndLists]
// List actions to perform during allocation.
// +optional
Lists map[string]ListAction `json:"lists,omitempty" hash:"ignore"`
}
Expand All @@ -128,12 +139,16 @@ type GameServerSelector struct {
// Players provides a filter on minimum and maximum values for player capacity when retrieving a GameServer
// through Allocation. Defaults to no limits.
Players *PlayerSelector `json:"players,omitempty"`
// (Alpha, CountsAndLists feature flag) Counters provides filters on minimum and maximum values
// [Stage: Alpha]
// [FeatureFlag:CountsAndLists]
// Counters provides filters on minimum and maximum values
// for a Counter's count and available capacity when retrieving a GameServer through Allocation.
// Defaults to no limits.
// +optional
Counters map[string]CounterSelector `json:"counters,omitempty"`
// (Alpha, CountsAndLists feature flag) Lists provides filters on minimum and maximum values
// [Stage: Alpha]
// [FeatureFlag:CountsAndLists]
// Lists provides filters on minimum and maximum values
// for List capacity, and for the existence of a value in a List, when retrieving a GameServer
// through Allocation. Defaults to no limits.
// +optional
Expand Down
19 changes: 14 additions & 5 deletions proto/allocation/allocation.proto
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,22 @@ message AllocationRequest {
// Note: This field can only be set if neither Required or Preferred is set.
repeated GameServerSelector gameServerSelectors = 8;

// (Alpha, CountsAndLists feature flag) The first Priority on the array of Priorities is the most
// important for sorting. The allocator will use the first priority for sorting GameServers in the
// Selector set, and will only use any following priority for tie-breaking during sort.
// Impacts which GameServer is checked first.
// [Stage: Alpha]
// [FeatureFlag:CountsAndLists]
// `Priorities` configuration alters the order in which `GameServers` are searched for matches to the configured `selectors`.
//
// Priority of sorting is in descending importance. I.e. The position 0 `priority` entry is checked first.
//
// For `Packed` strategy sorting, this priority list will be the tie-breaker within the least utilised infrastructure, to ensure optimal
// infrastructure usage while also allowing some custom prioritisation of `GameServers`.
//
// For `Distributed` strategy sorting, the entire selection of `GameServers` will be sorted by this priority list to provide the
// order that `GameServers` will be allocated by.
repeated Priority priorities = 9;

// (Alpha, CountsAndLists feature flag) Counters and Lists provide a set of actions to perform
// [Stage: Alpha]
// [FeatureFlag:CountsAndLists]
// Counters and Lists provide a set of actions to perform
// on Counters and Lists during allocation.
map<string, CounterAction> counters = 10;
map<string, ListAction> lists = 11;
Expand Down
19 changes: 14 additions & 5 deletions sdks/rust/proto/allocation/allocation.proto
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,22 @@ message AllocationRequest {
// Note: This field can only be set if neither Required or Preferred is set.
repeated GameServerSelector gameServerSelectors = 8;

// (Alpha, CountsAndLists feature flag) The first Priority on the array of Priorities is the most
// important for sorting. The allocator will use the first priority for sorting GameServers in the
// Selector set, and will only use any following priority for tie-breaking during sort.
// Impacts which GameServer is checked first.
// [Stage: Alpha]
// [FeatureFlag:CountsAndLists]
// `Priorities` configuration alters the order in which `GameServers` are searched for matches to the configured `selectors`.
//
// Priority of sorting is in descending importance. I.e. The position 0 `priority` entry is checked first.
//
// For `Packed` strategy sorting, this priority list will be the tie-breaker within the least utilised infrastructure, to ensure optimal
// infrastructure usage while also allowing some custom prioritisation of `GameServers`.
//
// For `Distributed` strategy sorting, the entire selection of `GameServers` will be sorted by this priority list to provide the
// order that `GameServers` will be allocated by.
repeated Priority priorities = 9;

// (Alpha, CountsAndLists feature flag) Counters and Lists provide a set of actions to perform
// [Stage: Alpha]
// [FeatureFlag:CountsAndLists]
// Counters and Lists provide a set of actions to perform
// on Counters and Lists during allocation.
map<string, CounterAction> counters = 10;
map<string, ListAction> lists = 11;
Expand Down
14 changes: 8 additions & 6 deletions site/content/en/docs/Guides/Client SDKs/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,13 +346,15 @@ Convenience function, which retrieves the length of the results of [`Alpha().Get

### Player Tracking

{{< alpha title="Player Tracking" gate="PlayerTracking" >}}
{{% pageinfo color="info" %}}
[Counters and Lists]({{< ref "/docs/Guides/counters-and-lists.md" >}}) will eventually replace the Alpha functionality
of Player Tracking, which will subsequently be removed from Agones.

{{< alert title="Warning" color="warning">}}
[Counters and Lists](#counters-and-lists) will eventually replace the Alpha functionality of Player Tracking, which will subsequently be
removed from Agones. If you are currently using this Alpha feature, we would love for you to test (and ideally migrate
to!) this new functionality to ensure it will meet all your needs.
{{< /alert >}}
If you are currently using this Alpha feature, we would love for you to test (and ideally migrate to!) this new
functionality to Counters and Lists to ensure it meet all your needs.
{{% /pageinfo %}}

{{< alpha title="Player Tracking" gate="PlayerTracking" >}}

#### Alpha().PlayerConnect(playerID)

Expand Down
Loading
Loading