Hi,
we are developing an online game using a game server written in Java.
We are wondering whether our use case of Hibernate could be one of the exception mentioned by the documentation, where the "Session-per-user-session" pattern is useful.
- The game server is stateful. All collections of a player are in the server's heap memory and stay there until the player leaves the server and by that stops playing.
- Each player has it's own thread that is associated to one permanent socket connection where the player updates come from. This connection/thread is the only source that manipulates the player's data.
- Each player has around 5 Collections like "how many enemies of what kind has this player killed" (approx. 200 entries), the player's inventory (approx. 500 entries),….. They are initialized lazily, when the user logs into the game server.
- When using the "session-per-operation" pattern the collections get detached from the session and because updates are saved via another session, the collections are reloaded from the database when the player is merged. This reloading is unnecessary because the player's thread is the only source that changes the data for this player and could be omitted with the session-per-user-session pattern.
- To avoid OutOfMemory-errors all information queried about other players would be evicted from the session after loading
- Performance is critical and when the player is saved to the database whenever he makes progress in the game or he picks up loot, etc.
The hibernate version is 3.5.4.
What do you guys think? Has anyone used the session-per-user-session pattern and could share some of his/her experience using it?
Thanks in advance Monterey
|