How to architect achievements and badges with nosql

I currently have a social gaming application using mongodb for its database. My question is, some suggestions if I want to create points and a badging system. The business logic of achievements / badges can become quite complex and very ad-hoc, so providing real-time badges would not seem effective. I suggest adding tracked actions to the queue somewhere, i.e. Amazon SQS, or simply using the user's activity feed as a queue, and also go through another workflow offline and simply process the consequences of each action / activity to find out if the threshold is set for any particular icon intersects.

My concern with this method is that it seems that icon requests can become quite intense, and I will also have to keep track of a very large number of activities. I can imagine achievements, ranging from things like the badge to those who in the last 4 weeks have scored 2nd place every week, or the badge to someone who has a friend in each of the 50 states ... and so on. .d.

Are there any more elegant or proven methods for this type of thing? Does it make sense to use a different database for achievements / activity feeds / leaders besides mongo, creating a mongo / other db hybrid environment?

Are options like Redis, Neo4J, or just the old SQL Server a good choice for a hybrid solution? I like Mongo so that it remains our main db, but it is curious to see if adding another db to the mix will help.

+5
source share
2 answers

This is a good candidate to run map reduction in the database. you can run them on a less regular basis, using them to autonomously calculate the data you want.

http://www.mongodb.org/display/DOCS/MapReduce

You can use other tools for this, but in the summary I see no good reason to add complexity at this point. I would study a map to reduce, try, and then, if it does not meet your needs, expand your capabilities. but at that time you at least identified specific bottlenecks, if any.

+3
source

Just some notes on using graphical db like Neo4j. How is your icon information always? requested for a specific user, these are local, not global, requests.

So, if you can simulate your domain as a network of objects (it is already possible as possible) and express the logic of the icons as a set of crawls or graph-queries , starting with the user, then it works without saving them, since the requests of the local graph are quite fast, regardless of the size of the dataset.

The easiest way to create a temporary PoC is to see if this works for you. Cross-connecting two repositories, storing your user ID in the graph-db index, and the property on node should work quite easily. You can synchronize the bit on commit / save commit or asynchronously. Perhaps it would be wise to transfer other data of the "social network" to the chart, as well as save game data + documents in mongodb.

0
source

All Articles