开发者

How can facebook deals with their databases informations?

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-e开发者_运维问答nd codes ?

Thank you


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.


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

struct myNode{
char num;
myNode* next;
}

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜