Currently using HTML5 WebSocket and PHP to achieve a socket connection, ready to do a long-connected game,
Ready to make a server to support 100 players around (go online and try to increase the number of people), a room/game 5-8.
Now there is a question as to where the current game data exists. (game result data will be stored in the database, mainly in the middle of the game data storage)
Global variables:
stored in global variables can certainly be achieved, performance is the best,
But if the process hangs, the current number of game data disappears, and all players have to start over from the game hall again.
Redis
Redis is relatively secure, the process is hung, the player should be able to continue the game after the process restarts,
But the performance is certainly worse than the global variable, do not know whether it is necessary to design.
(currently only ready to rent a server, do not know if Redis will not hang together)
The main is not know the probability of the process hangs out how much, there is the use of Redis on the performance of the impact of how much.
Is there any prior experience in this aspect that has been taught in this area?
Reply to discussion (solution)
Look forward to the landlord experience.
No one answered, thinking of a compromise solution:
Game first with the global variable implementation, Redis as anti-hang extension function, the game on-line confirmed that the server will hang, it is necessary to implement again.
Implementation method:
1. Synchronization scheme: Separate the data needed for each room's restoration into a single Redis field (named ' Room_ '). $roomId)
2. Sync time: 1. Initial information is stored at the beginning of the Game 2. Clear information at the end of the Game 3. The game holds data once per round
3. Restore scenario: After the process starts, read the Redis room data into global variables.
Anyway, let's start with global variables ...