I'd recommend using Redis. Its sorted set data type makes a high score list a breeze to maintain. As mentioned using a combination of RDB and AOF you get great durability with Redis.
-- Daniel R. <[email protected]> [http://danielr.neophi.com/] On Mon, Oct 1, 2012 at 6:10 AM, Felix E. Klee <[email protected]> wrote: > 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 [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en -- 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
