question

kerozard avatar image
kerozard asked

Custom game server availability

I stumbled a bit over the documentation in https://api.playfab.com/docs/custom-game-servers

[...]As such, an enabled build will always have at least one server available, so that a player attempting to join a session does not have to wait on server spin-up time.[...]

[...]It is also important to make certain that your server build exits once the last player leaves the session, for two reasons. First, the game server hosting service in PlayFab does not terminate game server instances explicitly.[...]

I am not sure how I am supposed to implement these requirements as they seem to be contradictory.

I assume that we can let the server running for a certain time when no player is present, because otherwise the server would shut down immediately after launch (since there are no clients connected yet). What time frame is acceptable in this scenario?

And how do I check on the server side how many servers are currently running? I have to somehow let the server know it is the last one so it doesn't shut down, but rather waits for players to join up.

Am I thinking about this the wrong way?

Thanks in advance,

Patrick

Custom Game Servers
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

The important distinction is between a game server host and a game server instance. The host is the machine where the instances run, while an instance is your custom game server code running on the host.

You do not need to do anything apart from activate your build in a region for the server to be available. When you activate a region, we start one or more game server hosts in that region, depending on your settings for how many instances can run on a host and how many instance slots need to be available at any given time (since a new host machine can take upwards of 12 minutes to be ready, between requesting the server from EC2, loading the server image onto it, downloading your custom game server zip, and decompressing that zip into the appropriate folder).

That way, your server code is ready to go at any time. When a server instance is requested via Matchmake or StartGame, information is passed to the requester. It is expected that the instance will have a thread available to receive requests from incoming players on start. If it takes more than a second or so for your server to be ready, you'll need to account for that in the client logic. Once running, the server should remain active for at least two minutes, waiting on players to join. If after that period no players have joined, it's fine for it to exit.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

kerozard avatar image kerozard commented ·

Makes total sense that way. I guess I was overthinking this. Thank you.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.