incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Metin Akat <akat.me...@gmail.com>
Subject How would you implement bulk doc changes happening on their own?
Date Sun, 05 Sep 2010 02:38:25 GMT
I asked this on #couchdb but it seems like the middle of the night is
not the best time for having such discussions there :)

Imagine Farmville, although my use case is not exactly the same.
Players in Farmville plant some crops and they grow up after some
time. Let's say 5 hours.
If we want to implement something like this in couchdb, how would you
do it, in a crash proof way? It's something like a _changes listener,
but well, happening some (long) time after the change has happened.

Here we have some requirements:

1. Even if they don't grow at exactly 5 hours but say at 5 hours +-
several minutes, crops must not stop growing totally for the whole
server. If it happens, this will do major damage to in-game economy,
because the other parts of the economy may still function (like buying
and selling etc), prices of crops will go sky high in half an hour. If
crops stop growing, the whole game world must stop. It's OK if
something (pseudorandomly) misbehaves, but it's not OK if the whole
economy misbehaves.

2. Growing must happen asynchronously for the different players. It
must not be a cron job executed every hour. Maybe every minute could
be OK, but it would cause peaks of server load every minute and I
don't like the idea very much.

3. All state should (if possible) be stored in couchdb. I don't want
to rely on storing anything in the memory of my application. It must
be crash proof. This implies that if couchdb crashes and is back
online after one hour, that one hour must not have affected crop
growth at all. If I plant my crops at 1pm and the game world is
offline from 2pm to 3pm, my crops must be ready for harvesting at 7pm
instead of 6pm.


Of course, I have been thinking of all kinds of weird stuff like
writing a "server is fine" every other minute and then after crash
have a look at when was it OK. Same for crop growth (some monitor to
check if growth is working fine and stop the game world otherwise),
but well, everything so far is at best awkward and doesn't feel good.
I guess there may not be a good solution to my problem (at least not
with couchdb). If so, I'd like to know that :)

Mime
View raw message