b) redis: http://redis.io/topics/introduction
its less puzzling than files, has replication and pubsub, and atomic 
operations
Am Montag, 1. Oktober 2012 12:10:50 UTC+2 schrieb Felix E. Klee:
>
> Somewhat as a training, I am developing a puzzle game. A first version 
> was entered into the js13kGames competition: 
>
> http://js13kgames.com/entries/rotogamesq 
>
> In that version, hiscores are simply stored in the browser. For the next 
> version, my idea is to store hiscores on a server running Node.js  / 
> express, hosted on Nodejitsu. How it could work: 
>
> Server starts: Hiscore lists for all puzzles are loaded from disk into 
> server memory. 
>
> User opens game in browser: 
>
>  1. Browser loads game. Via Socket.IO the hiscore lists for all puzzles 
>     are transferred to the browser. 
>
>  2. User finishes one puzzle, gets into hiscore list, and enters name. 
>
>  3. Via Socket.IO, data is sent to the server: puzzle, moves, name 
>
>  4. The server verifies that the moves are correct, using a background 
>     process. 
>
>  5. Name and new hiscore are entered into puzzle's hiscore list. 
>
>  6. The puzzle's hiscore list is written to disk. 
>
>  7. Using Socket.IO, the updated hiscore list is broadcasted. 
>
> Now I wonder what is the simplest way to perform step 6. I see two 
> options: 
>
>   * (A) Store hiscore list in a file `hiscores.json`, associated with 
>     the puzzle. Problems: 
>
>       - There *may* be concurrency issues. If two users finish the same 
>         puzzle near simultaneously, then `fs.writeFile` will be called 
>         in quick succession. I am not sure whether this could lead to 
>         file corruption. 
>
>       - For creating a backup, it doesn't seem possible to *download* 
>         files from Nodejitsu, unless I write my own software for that. 
>
>       - Although unlikely, suppose I scale up, and two Node.js are 
>         serving the game. In this case, there are further concurrency 
>         issues due to the hiscore lists held in memory not being shared 
>         among the processes. 
>
>   * (B) Store hiscore list in database, e.g. Mongo. Problems: I don't 
>     see any, except that the solution feels fat, a database needs to be 
>     set up, and I prefer individual files for simplicity. 
>
> After writing this email, I tend to option (B), but still: 
>
> Which option would you chose? Something else? Suggestions? 
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to