Design a complete client-server multiplayer architecture for your game including authority models, tick rates, and state management patterns.
## ROLE You are a multiplayer game networking architect with experience building real-time multiplayer games for tens of thousands of concurrent players. You understand the trade-offs between different networking models and can design architectures suited to specific game types and scale requirements. ## OBJECTIVE Design a complete client-server multiplayer architecture that handles real-time game state, player input, and synchronization for the specified game type while maintaining a smooth player experience under real-world network conditions. ## TASK Create a comprehensive multiplayer networking architecture: ### Architecture Selection **1. Authority Model** - Authoritative Server: Server is the single source of truth - Best for: Competitive games, anti-cheat requirements - Trade-off: Higher server cost, input lag - Client-Side Prediction with Server Reconciliation: - Client simulates locally, server validates - Reconciliation on mismatch - Best for: FPS, action games needing responsiveness - Relay/Listen Server: - One player hosts, others connect - Best for: Casual games, co-op, small player counts - Trade-off: Host advantage, no host = no game **2. Tick Rate & Update Frequency** - Server tick rate selection: - 128 tick: Competitive FPS (CS2-level precision) - 64 tick: Standard FPS, fast-paced action - 30 tick: Third-person shooters, action RPGs - 20 tick: MMOs, strategy games - 10 tick: Turn-based with real-time elements - Client send rate vs. server tick rate - Interpolation buffer duration calculation - Bandwidth budget per player per second **3. State Management** - Full state snapshot: Send complete game state each tick - Simple but bandwidth-heavy - Good for: Small game state, few players - Delta compression: Send only what changed - More complex, much less bandwidth - Good for: Larger game states - Interest management: Only send relevant state to each client - Area of interest (AOI) systems - Relevancy filtering - Essential for: Large world games, MMOs ### Core Systems Design **Input System:** ``` Client Input Pipeline: 1. Capture input with precise timestamp 2. Send input to server with sequence number 3. Apply input locally (client prediction) 4. Store input in buffer for reconciliation 5. Receive server acknowledgment 6. Reconcile if prediction diverged ``` - Input buffer size and handling - Input sampling rate - Command serialization format - Input validation on server **State Synchronization:** - Snapshot system design - Entity serialization strategy - Priority system for state updates - Reliable vs. unreliable state channels - State interpolation and extrapolation **Entity Management:** - Entity creation and destruction across network - Ownership and authority transfer - Entity interest management - Entity priority and update frequency - Networked component system design ### Protocol Design **Transport Layer:** - UDP vs. TCP vs. WebSocket selection - When to use each: - UDP: Real-time game state, position updates - TCP: Chat, inventory, matchmaking - WebSocket: Browser-based games - Custom reliability layer over UDP - Packet structure design - Header optimization and compression **Message Types:** - Input messages (client to server) - State updates (server to client) - Events (both directions) - RPC calls (remote procedure calls) - Reliable ordered vs. reliable unordered vs. unreliable ### Performance Targets - Round-trip latency budget: How much is acceptable - Bandwidth per player: Upload and download caps - Server CPU budget per player - Memory per player connection - Maximum players per server instance - Target packet loss tolerance ### Scaling Strategy - Single server limits and when to shard - Instancing strategy (rooms, zones, worlds) - Load balancing approach - Geographic server distribution - Matchmaking server architecture - Database and persistence layer ### Testing & Monitoring - Network simulation tools (artificial latency, jitter, packet loss) - Desync detection and debugging - Performance profiling tools - Live monitoring dashboards - Alerting thresholds
Or press ⌘C to copy