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

feat: allow maestro to deal with multiple matches per game server #646

Merged
merged 4 commits into from
Nov 25, 2024

Conversation

reinaldooli
Copy link
Collaborator

This pull request introduces changes to enable Maestro to manage multiple matches per Game Server effectively.

  • MatchAllocation Configuration: Adds a MatchAllocation block to the Scheduler configuration with two parameters: MaxMatches (maximum number of matches per game room) and MinFreeSlots (minimum number of free slots required for a room to be considered available again).

  • Backward Compatibility: If MaxMatches is set to 1 (default value), Maestro will continue its previous behavior without slot-based scaling. The new match-based calculations apply only when MaxMatches is greater than 1.

  • New Game Server States: Introduces two new statuses for Game Servers with MaxMatches greater than 1:

    • Active: Game Servers that are hosting matches but are not yet at full capacity.
    • Cooling: Game Servers that have reached full capacity and will only transition back to Active after the number of running matches falls below MinFreeSlots.

These updates provide more granular control over room availability and autoscaling, helping to optimize server utilization when using a multiple-matches-per-room strategy.

@reinaldooli reinaldooli requested a review from hspedro October 29, 2024 13:50
@reinaldooli reinaldooli self-assigned this Oct 29, 2024
MaxMatches int `validate:"required,min=1,max=30"`
// MinFreeSlots defines the minimum number of free slots that a room must
// have to become available for allocation.
MinFreeSlots int `validate:"required,min=1"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should add max=30 here because the upper limit is MaxMatches, right? And in addition we'll validate one value against the other as well but max=30 we "gain" a validation prior to us checking one against the other

* feat: add new metrics
* fix: metrics reporter tests
* fix: protobuf linter offenses
* fix: update buf dependencies before running linter
@reinaldooli reinaldooli merged commit e5202db into chore/deps-upgrade Nov 25, 2024
6 checks passed
@reinaldooli reinaldooli deleted the feature/slot-calculations branch November 25, 2024 16:49
reinaldooli added a commit that referenced this pull request Nov 25, 2024
* chore: upgrade and remove some dependecies
* feat: allow maestro to deal with multiple matches per game server (#646)
* feat: allow maestro to deaul with multiple matches per game server
* fix: removing cooling status
* feat: add new metrics (#649)
* feat: add new metrics
* fix: metrics reporter tests
* fix: protobuf linter offenses
* fix: update buf dependencies before running linter
* fix: add max validation to minFreeSlots fields
reinaldooli added a commit that referenced this pull request Nov 25, 2024
* feat: add occupied slots to game rooms api
* fix: rename api parameter
* fix: failing tests
* chore: upgrade and remove some dependencies (#644)
* chore: upgrade and remove some dependecies
* feat: allow maestro to deal with multiple matches per game server (#646)
* feat: allow maestro to deaul with multiple matches per game server
* fix: removing cooling status
* feat: add new metrics (#649)
* feat: add new metrics
* fix: metrics reporter tests
* fix: protobuf linter offenses
* fix: update buf dependencies before running linter
* fix: add max validation to minFreeSlots fields
reinaldooli added a commit that referenced this pull request Jan 22, 2025
* feat: add occupied slots to game rooms api (#641)
* feat: add occupied slots to game rooms api
* fix: rename api parameter
* fix: failing tests
* chore: upgrade and remove some dependencies (#644)
* chore: upgrade and remove some dependecies
* feat: allow maestro to deal with multiple matches per game server (#646)
* feat: allow maestro to deaul with multiple matches per game server
* fix: removing cooling status
* feat: add new metrics (#649)
* feat: add new metrics
* fix: metrics reporter tests
* fix: protobuf linter offenses
* fix: update buf dependencies before running linter
* fix: add max validation to minFreeSlots fields
* feat: removing unused field minFreeSlots
* chore: update dependencies
* fix: project dependencies
* chore: upgrading go version on CI
* chore: upgrade docker image for build step
* fix: backward compatibility with exiting schedulers
* fix: linter offenses
* fix: adding default match allocation configuration when not provided
* fix: missing match allocation configuration
* feat: create simulation service
* fix: missing license headers
* fix(policy): compute desired number of matches before rooms (#654)
If we first divide the number of running matches per maxMatches
we might end up with a number between 0 and 1, which is quirky
when using math.Ceil because it would propagate the error to when
computing number of desired rooms. To simplify and fix this, instead
we now compute how many matches is the desired and then convert
the final number to the amount of rooms/instances/pods needed to
provide this number of matches:

1. How many running matches we have?
* Get the value from the redis: scheduler:<scheduler_name>:occupancy
2. How many matches do we need to have based on readyTarget?
* Divide running matches by 1 - readyTarget
3. How many game rooms are needed to provide this amount of matches?
* Get the desired number of matches and divide by the max number of matches
per room as defined in the scheduler

* fix(allocation): maxMatches limit to 35 (#655)
Some games might choose to run larger pod resources and increase number
of matches running in each room/instance, thus increasing from 30 to 35.
The limit in the max matches is useful so configuration stays in a sane
number to help in autoscaling and roundings.

* fix: setting running matches when not given
* fix: adding transition from unready to active
* fix: adding transition from occupied to active
* fix: multiple matches status calculation
* feat: report metric with scheduler max matches
* fix: sync scheduler before sending metrics

---------

Co-authored-by: Pedro Soares <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants