kruise-game
kruise-game copied to clipboard
[Enhance] Reconstruct the logic of GameServers Scaling
Concepts involved
- Explicit reserve ID: user-specified reserveGameServerIds
- Implicit reserve ID: non-user-specified reserveGameServerIds, due to the OKG shrinking feature rather than the last ID sequence number
- Existing ID: ID list managed by the current GameServerSet
Principle
- Explicit reserve ID has the highest authority, represents user instructions, and the ID referred to must not exist in the list
- Try not to change the existing POD ID list to ensure minimal changes
Logic
- Explicit reserve ID and implicit reserve ID are converted to each other
- Delete explicit reserve ID in existing ID
- If the number of existing ID is less than the expected number at this time, expand
- First select a small sequence number from implicit reserve ID to fill
- If all the sequences of implicit reserve ID are insufficient, select from the current existing ID The last serial number increases, and avoid touching the explicit reserve ID during the increase process
- If the number of existing ID is greater than the expected number at this time, continue to shrink
- Scaling according to OKG scaling features, put the shrinking serial number into the implicit reserve ID
牵扯概念
- 显式reserve ID:用户指定的reserveGameServerIds
- 隐式reserve ID:非用户指定的reserveGameServerIds,由于OKG缩容特性而非末尾ID序号
- 已存在 ID:当前GameServerSet管理的ID列表
原则
- 显式reserve ID具有最高权限,代表用户指令,所指ID一定不会存在于列表
- 尽量不改动存量POD ID列表,保证最小改动
逻辑
- 显式reserve ID 与 隐式reserve ID 相互转化
- 删去 已存在 ID 中的 显式reserve ID
- 若此时 已存在 ID 的数量少于期望数量,则进行扩充
- 首先从 隐式reserve ID 中选择小序号进行填充
- 若 隐式reserve ID 所有序号都不足够,则从当前已存在 ID 最末序号增加,增加过程中避免触碰 显式reserve ID
- 若此时 已存在 ID 的数量大于期望数量,则继续缩容
- 按照OKG缩容特性进行缩容,将缩容的序号放入 隐式reserve ID