Best Practices
Follow recommended patterns to optimize lobby performance by using events instead of polling and maintaining active lobbies.
Read time 1 minuteLast updated 17 hours ago
The Lobby service is very flexible and can be used for a wide variety of different scenarios, but there are a few patterns and practices that you should generally try to follow to provide the best experience for your users.
Prefer using events instead of polling
Polling a lobby will result in longer delays between changes to the lobby being synchronized and will result in higher bandwidth and compute usage by the client. Events will ensure that clients only do work when there is a change to the lobby metadata.Lobbies are not "realtime"
Try to avoid using a lobby to pass "realtime" data. Lobbies are intended to be used to find other players and then connect to them using some other mechanism (e.g. a direct P2P connection, or a Relay. These "realtime" connections allow much faster communication between clients and are much more efficient for passing larger amounts of data. As a general rule of thumb, you should store data in a lobby that would likely be used to find or filter lobbies, or certain private data that needs to be accessible to all lobby members. For example:- Map Type: Free For All - Public lobby data to enable a player to find a specific game mode.
- Player Character: Mage - Public player data used to determine whether someone is already in the lobby with a specific character class.
- Dedicated Server Connection Key: [something secret] - Private lobby data that members use to connect to a game server.