社交网络的Neo4j图模型 [英] Neo4j graph model for a social network

查看:281
本文介绍了社交网络的Neo4j图模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为社交网络创建了一个图形模型,并且需要有关缩放设计的一些具体建议.请原谅这些问题,但我没有找到很多明确的例子...

I've created a graph model for a social network and needed some concrete advice regarding the design in regards to scaling. Pardon the n00bness of these questions but I'm not finding very many clear examples out there...

注意:状态更新和活动节点/关系是链接列表-最新条目始终位于列表顶部.

NOTE: the status updates and activity nodes /relationships are linked lists - with the newest entries constantly being placed at the top of the list.

  1. 链接列表允许生成新闻提要,但每个用户可能有数百条记录-我认为即使数据按日期降序,limit子句也不足够.我是否必须有一个单独的链接列表,该列表仅包含最近的10个状态/活动更新),并不断替换该列表上的标题以获取更好的活动供稿,还是将一个列表正确排序并完成工作(使用限制条款)

  1. Linked lists allow for news feed generation, but there could be hundreds of records per user - I presume the limit clause isn't sufficient even though the data is in descending order by date. Do I have to have a separate linked list that would only hold the most recent 10 status/activity updates) and constantly replace the head on that list to get better activity feed generation, or will one list properly sorted and do the job (with a limit clause)

这些节点都具有属性(带有内容,ID等的json数据)-全局"索引如何在这里发挥作用,例如,我可以找到喜欢Depeche Mode的用户而无需等待一生为了结果?我知道如何向索引添加节点,只是想知道我是否在这里缺少图片的一部分..

These nodes all have properties (json data with content, IDs, etc) - how do "global" indexes come into play here so that I can find, for example, users that like Depeche Mode without waiting a lifetime for results? I know how to add a node to an index, just wondering if I'm missing a part of the picture here..

安全性-登录名和密码.我假设图形数据库可以存储它们,但是我认为此时存在安全隐患-将其保存在postgres等中会更好吗?

Security - logins and passwords.. I would presume a graph database could store them, but I'd presume it's a security risk at this point - would it be better to keep this in postgres etc?

您将如何改进此模型以处理可伸缩性?想象一下,有2000万用户对此感到震惊.

How would you improve this model to handle scalability? Imagine 20 million users banging away on this..

想象一下4000万用户-这种模型在可伸缩性方面有什么问题?

Imagine 40 million users - what's wrong with this model when it comes to scalability?

推荐答案

第1部分.

您可以编写满足您需要的密码查询或gremlin查询.请记住,您可以在边缘上前后移动.对于用户而言,拉近他们所做的最后十件事应该始终是相对固定的时间.

You can write cypher or gremlin queries that do what you want. Remember that you can traverse forwards and backwards on edges. Given a user, it should always be relatively constant time to pull up the last ten things they did.

第2部分.

如果要将乐队表示为某种类型的实体,请对该属性进行索引.然后,您将能够拉出该节点并向外遍历以找到喜欢该乐队的所有用户.如果没有独立实体,或者以某种方式隐含实体,则需要为各自的图形数据库启用全文本搜索.

If you are representing a band as an entity of a certain type, index on that attribute. Then you'll be able to pull out that node and traverse outwards to find all the users who like that band. If you don't have an independent entity, or it is somehow implicit, you'll want to enable full text search for your respective graph database.

第3部分.

详细了解安全性.您将要存储的唯一内容是正确加密的用户密码字符串.届时,使用任何graph数据库和良好的安全性做法都可以.

Learn more about security. The only thing you would be storing would be a properly hashed string of the user's password. At that point you would be fine using any graph db and good security practices.

第4/5部分.

一旦您拥有一个用户,就可以担心下一个用户.

Once you have one user, worry about the next thousand.

当您有一千个用户时,请担心下一个十万个用户.

When you have a thousand users, worry about the next hundred thousand.

当您有十万时,请担心下百万.

When you have one hundred thousand, worry about the next million.

拥有100万用户时,您可以开始担心所提出的问题.

When you have a million users, you can start worrying about the questions you asked.

直到您要扩展到至少0.1%的用户/卷,这是一种心理自慰,您可以尝试提出有关如何扩展到特定大小的问题.

Until you have at least 0.1% of the users/volume you want to scale to, it's mental masturbation to try and ask questions about how to scale up to a certain size.

这篇关于社交网络的Neo4j图模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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