Facebook 如何处理其数据库信息?
大家好,
在工作闲暇时间浏览了一下之后,我偶然发现了 Facebook 统计数据 页面。
“超过300亿枚 内容...每月共享。”
我们可以假设每月大约有 20 亿条帖子。目前,我 相信MySQL在处理如此大量的信息时不会有任何问题,因为最大 无符号 BIGINT 的值为 18 446 744 073 709 551 615。我假设他们使用数字 PK 优化目的。
令我困惑的问题是,在 C++ 中,最大无符号长整型值是 4 294 967 295. 当数据库的值发生变化时,他们如何处理数据库的主键 现在可能太大而无法在后端代码中处理?
谢谢
Good day guys,
After browsing a bit in my spare time at work, I stumbled upon the Facebook statistics page.
"More than 30 billions pieces of
content ... shared each month."
We can assume there are probably around let's say 20ish billions posts a month. For now, I
believe MySQL will have no problem dealing with such amount of informations since the maximum
value of an unsigned BIGINT is 18 446 744 073 709 551 615. I assume they use numeric PK for
optimisation purpose.
The question that boggle my mind is that in C++, the maximum unsigned long integer value is
4 294 967 295. How are they dealing with their database's primary keys when their's values
are now probably too large to be dealt with, in their back-end codes ?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
那么 64 位长、与 BIGINT 完全相同的
unsigned long long
呢? :)另外,我相信 Facebook 不会在其数据库中使用数字 ID,因为在具有并行插入的多服务器数据库配置中很难做到这一点。
What about
unsigned long long
which is 64-bit long, exactly as BIGINT? :)Also, I believe that Facebook do not use numeric ids for their DB, because it is very hard to do that at multiserver database configuration with parallel inserts.
很简单,您可以在 C++ 中编写自己的 BIGINT 数据类型类来处理非常非常大的数字(实际上可能在内部表示为字符串)。
我的意思是考虑一个链接列表
现在链接列表可以容纳比您期望的典型 long / int 更多的整数。
这并不意味着我知道 Facebook 在做什么或使用什么,但有很多变化。另外,Facebook 太大了,所有数据不仅仅保存在一个数据库中......您还可能对技术和编程语言以及数据库供应商做出假设。
他们可以使用 GUID :),他们可以使用 Oracle 甚至 SQL Server。
这些服务器肯定是负载平衡的,并且分布在美国各地的许多服务器上,也可能分布在美国境外。这不是一个简单的应用程序,但它看起来确实像一个。
Simple you write your own BIGINT datatype class in C++ to handle very very large numbers (that may be internally represented as strings actually).
What I mean by this is think of a linked list
Now the linked list can hold a lot more integers than you'd expect a typical long / int to.
That doesnt mean I know what facebook is doing or using but there are so many variations. Also facebook is so large all the data isn't kept in just one database...You also may be making assumptions about technology and programming languages as well as DB vendors.
They could be using GUID :), they could be using Oracle or even SQL Server.
There servers are definately load balanced and spread across many many servers across the US and probably outside of the US as well. It's not a simple app but it sure looks like one.
如果您使用 64 位系统(这已经是 Windows 7 台式电脑的默认系统),您可以数到 40 亿乘以 40 亿。
如果 40 亿人在 Facebook 上在线,他们都可以发表 40 亿条评论,并且您仍然可以将所有评论存储在具有 64 位密钥的单个表中。
If you use 64 bit systems (which is already the default for Windows 7 desktop PC's), you can count to 4 billion times 4 billion.
If 4 billion people are online in facebook, they can all make 4 billion comments, and you can still store all of them in a single table with a 64 bit key.