如何使用nosql来构建成就和徽章 [英] how to architect achievements and badging with nosql

查看:278
本文介绍了如何使用nosql来构建成就和徽章的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个使用mongodb的社交游戏应用程序,它的数据库。我的问题是,如果我想创建一个积分和徽章系统,有什么建议。成就/徽章的业务逻辑可能变得相当复杂,非常特别,因此实时奖励徽章看起来效率似乎不高。我想象的是将跟踪的动作添加到某个队列(即Amazon SQS),或者仅使用用户的活动Feed作为队列,并使另一个脱机工作进程正在进行,并处理每个操作/活动的影响,以查看是否为任何特定的徽章都被越过。



我用这种方法担心的是,看起来徽章查询可能变得相当密集,我也必须跟踪一个非常大的数字的行动。我可以设想成就,例如像过去四周每周获得第二名的人的徽章,或者在50个州的每一个人中都有一个朋友的徽章...等等。



这种类型的东西有更优雅或者真正的方法吗?除了mongo之外,使用另一个数据库来获得成就/活动Feed /排行榜是否有意义?创建一个mongo /其他db混合环境?



可以选择像Redis,Neo4J或简单的旧SQL Server是混合解决方案的不错选择?我喜欢Mongo,所以这将保持为我们的主数据库,但好奇的是,如果添加另一个数据分析器将有助于。

解决方案

这是在数据库上运行map reduce的好选择。您可以不经常地运行它们,使用它们离线计算所需的数据。



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



您可以使用其他工具来执行此操作,但在摘要中,我无法看到有任何引人注目的理由增加复杂性阶段。我会探索地图缩小,尝试,然后如果不符合你的需要,扩大你的选择。但在那个时候,你至少会确定具体的瓶颈(如果有的话)。


I currently have an social game app using mongodb for it's database. My question is what are some suggestions if I want to create a points and badging system. The business logic for achievements/badges could become quite complicated and are very ad-hoc so doing real-time awarding of badges would not seem efficient. I am imagining adding tracked actions to a queue somewhere, i.e. Amazon SQS, or just using a user's activity feed as a queue, and have another offline worker process going through and just processing the effects of every action/activity to see if the threshold for any particular badge is crossed.

My worry with this method is that it seems like the badge queries can become quite intensive and I'd also have to track a very large number of actions. I can envision achievements ranging from things like a badge for someone that's scored 2nd place every week for the past 4 weeks, or a badge for someone that has a friend in every single one of 50 states... etc...

Are there more elegant or tried-and-true methods for this type of stuff? Would it make sense to use another database for achievements/activity feed/leaderboards besides mongo, creating a mongo/other db hybrid environment?

Are choices like Redis, Neo4J, or just plain old SQL Server a good choice for a hybrid solution? I like Mongo so that will stay as our primary db, but curious to see if adding another db to the mix would help.

解决方案

This is a good candidate for running map reduce on the database. you can run them on a less regular basis, using them for offline computation of the data that you want.

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

You could use other tools to do this, but in your summary i cannot see any compelling reason to add complexity at this stage. I would explore map reduce, try it out and then if it does not meet your needs, expand your options. but at that time, you would at least have identified concrete bottlenecks, if any.

这篇关于如何使用nosql来构建成就和徽章的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆