GameServer States
A GameServer progresses through several states during its lifetime:Scheduled
The GameServer pod has been scheduled to a node but is not yet running. This is a brief transitional state.
RequestReady
The GameServer pod is running and waiting for your game server to call
Ready(). This is where initialization happens.Ready
Your game server called
Ready() and is available for allocation. The server will remain in this state until allocated or deleted.Reserved
The server is temporarily reserved via
Reserve() and cannot be allocated. It will return to Ready after the reservation expires.Allocated
The server has been allocated to a game session via GameServerAllocation. This is where players connect and play.
Shutdown
Your game server called
Shutdown() or the pod is being terminated. The server will be deleted shortly.
Core Lifecycle Methods
Ready()
Marks your game server as ready to accept player connections. This transitions the state fromRequestReady to Ready.
When to call Ready(): After your server has finished initialization, loaded maps/assets, and is ready to accept player connections.
Shutdown()
Signals that your game server is shutting down gracefully. This transitions the state toShutdown and marks the server for deletion.
When to call Shutdown(): When a game session ends, when handling SIGTERM, or when you want to terminate the server gracefully.
Allocate()
Marks the GameServer asAllocated without going through GameServerAllocation. This is useful for self-allocation scenarios.
Most deployments use GameServerAllocation instead of self-allocation. Use
Allocate() only when implementing custom allocation logic.Reserve()
Marks the GameServer asReserved for a specified duration. Reserved servers cannot be allocated but will return to Ready after the duration expires.
Advanced Lifecycle Patterns
Server Reuse Pattern
Return servers to the Ready state after game sessions end to reuse them for multiple matches:See the Server Reuse Pattern guide for best practices and complete examples.
Delayed Shutdown Pattern
Automatically shut down after N allocations or after a timeout:Graceful Degradation Pattern
Return to Ready state on errors, or Shutdown if critical:Monitoring State Changes
WatchGameServer()
Receive real-time updates when your GameServer configuration changes:GetGameServer()
Retrieve current GameServer information on-demand:Best Practices
Call Ready() Once
Only call
Ready() after your server is fully initialized. Don’t call it multiple times unless returning from an Allocated state.Handle SIGTERM
Always listen for SIGTERM signals and call
Shutdown() for graceful termination.Use WatchGameServer
Monitor state changes with
WatchGameServer() instead of polling GetGameServer().Clean Up Before Shutdown
Disconnect players, save state, and close connections before calling
Shutdown().Troubleshooting
Server stuck in RequestReady
Server stuck in RequestReady
Cause: Your game server never called
Ready().Solution: Ensure Ready() is called after initialization. Check logs for errors preventing the call.Server marked as Unhealthy
Server marked as Unhealthy
Cause: Health checks failed or
Ready() took too long.Solution:- Call
Ready()within the grace period - Increase
spec.health.initialDelaySeconds - Ensure health pings are sent regularly
Shutdown not working
Shutdown not working
Cause: The shutdown call failed or the pod terminated before cleanup.Solution:
- Check SDK connection is alive
- Increase
terminationGracePeriodSeconds - Log errors from
Shutdown()call
Server doesn't return to Ready
Server doesn't return to Ready
Cause: Error calling
Ready() after game session or server in wrong state.Solution:- Check the current state before calling
Ready() - Cannot return to Ready from Shutdown state
- Check for SDK connection errors
Next Steps
Health Checking
Configure health monitoring for your servers
SDK Overview
Explore SDK features for your language
Server Reuse Pattern
Implement efficient server reuse
Allocation
Learn how to allocate game servers
