如何使用 nosql 构建成就和徽章

发布于 2024-12-13 19:43:50 字数 524 浏览 2 评论 0原文

我目前有一个使用 mongodb 作为数据库的社交游戏应用程序。我的问题是,如果我想创建一个积分和徽章系统,有哪些建议。成就/徽章的业务逻辑可能会变得非常复杂并且非常临时,因此实时授予徽章似乎效率不高。我想象将跟踪的操作添加到某个队列(即 Amazon SQS),或者仅使用用户的活动源作为队列,并让另一个离线工作进程执行并仅处理每个操作/活动的效果,以查看阈值是否为任何特定的徽章都会被划掉。

我对这种方法的担心是,徽章查询似乎会变得非常密集,而且我还必须跟踪大量的操作。我可以想象各种成就,比如为过去 4 周内每周获得第二名的人颁发徽章,或者为在 50 个州中的每一个州都有朋友的人颁发徽章……等等……

还有更多吗?对于这种类型的东西有优雅的或经过验证的方法吗?除了 mongo 之外,使用另一个数据库来获取成就/活动提要/排行榜是否有意义,创建 mongo/其他数据库混合环境?

Redis、Neo4J 或普通的旧式 SQL Server 等选择对于混合解决方案来说是不错的选择吗?我喜欢 Mongo,因此它将保留作为我们的主要数据库,但很想知道添加另一个数据库是否会有所帮助。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

丿*梦醉红颜 2024-12-20 19:43:50

这是在数据库上运行 MapReduce 的良好候选者。您可以不那么定期地运行它们,使用它们来离线计算您想要的数据。

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

您可以使用其他工具来做到这一点,但在你的总结中,我看不到任何令人信服的理由来增加现阶段的复杂性。我会探索地图缩减,尝试一下,如果它不能满足您的需求,请扩展您的选择。但那时,您至少会发现具体的瓶颈(如果有的话)。

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.

━╋う一瞬間旳綻放 2024-12-20 19:43:50

只是一些关于使用像 Neo4j 这样的图形数据库的注释。至于你的徽章信息总是?针对具体用户的查询这些是本地查询,而不是全局查询。

因此,如果您可以将您的域建模为对象网络(可能已经是这样)并将您的徽章逻辑表达为一组 遍历图形查询 从用户开始,然后它就可以工作而无需保留它们,因为无论数据集大小如何,本地图形查询都足够快。

最简单的事情是创建一个有时间限制的 PoC,看看它是否适合您。通过将用户 ID 存储在 graph-db 索引中并将其作为节点上的属性来交叉连接两个存储应该相当容易。您可以在提交/保存挂钩上或异步同步数据库。也许将其他“社交网络”数据也移入图中并将游戏数据+文档保留在 mongodb 中是明智的。

Just some notes on using a graph-db like Neo4j. As your badge information is always? queried for a concrete user these are local and not global queries.

So if you can model your domain as network of objects (as it perhaps already is) and express your badge logic as a set traversals or graph-queries starting at the user then it works without persisting them as local graph queries are fast enough regardless of data set size.

Easiest thing is to create a time-boxed PoC to see if that works for you. Cross-connecting the two stores by storing your user-id in an graph-db index and as property on the node should work fairly easily. You can sync the db's on the commit/save hooks or asynchronously. Perhaps it would be sensible to move other "social-network" data into the graph as well and keep the game data + documents in mongodb.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文