Domanda

Io lo scopo di creare un browser game dove i giocatori possono creare edifici.

Ogni edificio avrà più moduli (motori, uffici, linee di produzione, ...). Ogni modulo avrà enentually una o più azioni in esecuzione, come la creazione di 2OO 'articolo X' con ingredienti Y, Z.

Il server di gioco sarà impostato con Erlang: Un'applicazione OTP come il server stesso, e azoto come la parte anteriore web. Ho bisogno di persistenza dei dati. Stavo pensando a quanto segue:

Quando qualcuno o qualcosa interagisce con un edificio o di un timer che rappresenta alcuni capi della linea di produzione fino, un supervisore genera un gen_server (se non già deposto le uova), che carica lo stato della costruzione da un database, in modo che il gen_server può rispondere messaggi come 'inserire questo modulo', 'inizia questa azione', 'salvare questa produzione al magazzino', 'die', ecc (

Ma quando un edificio non ricevono alcun messaggio durante secondi X o minuti, che terminerà (grazie alla funzione gen_server timeout) e rilasciare le spalle stato corrente nel database.

Quindi, come sarà un (soft) gioco in tempo reale, il gen_server deve essere impostato molto velocemente. Stavo pensando di membase come database, perché è noto per avere molto buon tempo di risposta.

La mia domanda è: quando un server gen è di un esecuzione, i suoi stati riempie un po 'di memoria, e questo stato è presente nella memoria gestita da membase troppo, quindi l'uso dello stato due volte la sua dimensione in memoria. È una cattiva progettazione?

È membase una buona soluzione per manico persistenza nel mio caso? sarebbe l'uso mnesia una scelta migliore, o qualcos'altro?

temo mnesia 2 Go (o 4?) Limite di dimensione tavolo perché non so al momento la dimensione media dello stato dei miei gen_servers (edifici in questo esempio, butalso giocatori, linee di produzione, a prescindere) e io possa avere un giorno più di 1 giocatore:)

Grazie

È stato utile?

Soluzione

I agree with Hynek -Pichi- Vychodil. Riak is a great thing for key-valye storage.

We use Riak almost 95% for the same thing you described. Everything works so far without any issues. In case you will hit performance limitation of Riak - add more nodes and it good to go!

Another cool thing about Riak is its very low performance degradation over the time. You can find more information about benchmarking Riak here: http://joyeur.com/2010/10/31/riak-smartmachine-benchmark-the-technical-details/

In case you go with it:

About membase and memory usage: I also tried membase, but I found that it is not suitable for my tasks - (membase declares fault tolerance, but I could not setup it in the way it should work with faults, even with help from membase guys I didn't succeed). So at the moment I use the following architecture: All players that are online and play the game are presented as player-processes (gen_server). All data data and business logic for each player is in its player-process. From time to time each player-process desides to save its state in riak.

So far seems to be very fast and efficient approach.

Update: Now we are with PostgreSQL. It is awesome!

Altri suggerimenti

You can look to bitcask or other Riak backends to store your data. Avoid IPC is definitely good idea, so keep it inside Erlang.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top