From 9e3ad3f4a063c0611299eb41a66b823d96d2bb99 Mon Sep 17 00:00:00 2001 From: mvlabat Date: Sun, 21 Nov 2021 01:43:40 +0200 Subject: [PATCH 1/2] Make game servers mark them as allocated to prevent downscaling --- libs/server_lib/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/server_lib/src/lib.rs b/libs/server_lib/src/lib.rs index fad72ce0..0108d620 100644 --- a/libs/server_lib/src/lib.rs +++ b/libs/server_lib/src/lib.rs @@ -130,7 +130,7 @@ pub fn init_level( if let Some(agones) = agones { let mut sdk = agones.sdk.clone(); TOKIO.spawn(async move { - if let Err(err) = sdk.mark_ready().await { + if let Err(err) = sdk.allocate().await { log::error!( "Failed to mark the Game Server as ready, exiting: {:?}", err From f2d7ca5f86f2e5f73d025fa0d9c54963051134b1 Mon Sep 17 00:00:00 2001 From: mvlabat Date: Sun, 21 Nov 2021 01:46:34 +0200 Subject: [PATCH 2/2] Fix calculating desired game server replicas count --- bins/matchmaker/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bins/matchmaker/src/main.rs b/bins/matchmaker/src/main.rs index e8b0b7ff..b9b36c9e 100644 --- a/bins/matchmaker/src/main.rs +++ b/bins/matchmaker/src/main.rs @@ -289,9 +289,9 @@ async fn serve_webhook_service(tx: Sender, servers: Servers) let servers = servers.all().await; let active_players = tx.receiver_count() as u32 + servers.iter().map(|s| s.player_count).sum::() as u32; - let total_capacity = servers.iter().map(|s| s.player_capacity).sum::() as u32; + let desired_replicas_count = + active_players.unstable_div_ceil(PLAYER_CAPACITY as u32); - let desired_replicas_count = active_players.unstable_div_ceil(total_capacity); fleet_autoscale_review.response = Some(FleetAutoscaleResponse { uid: fleet_autoscale_review.request.uid.clone(), scale: desired_replicas_count != fleet_autoscale_review.request.status.replicas,