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

查看:35
本文介绍了社交网络的 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. 链接列表允许生成新闻提要,但每个用户可能有数百条记录 - 即使数据按日期降序排列,我也认为限制条款是不够的.我是否必须有一个单独的链表来只保存最近的 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 部分.

您可以编写 cypher 或 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 部分.

详细了解安全性.您唯一要存储的是用户密码的正确散列字符串.那时您可以使用任何图形数据库和良好的安全实践.

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.

当您拥有一百万用户时,您可能会开始担心您提出的问题.

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天全站免登陆