TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 11-09-2009, 03:37 PM   #1 (permalink)
The Acquainted
 
Join Date: Sep 2007
Posts: 126
Thanks: 4
Sam Granger is on a distinguished road
Default How does Facebook store all that information?

Hey guys!

I'm quite interested in scalability and was wondering, how does Facebook manage to have such a huge database?! Surely it's spread over multiple databases, how does it know what page/user is stored in what database(s)/server(s)? Might seem like a silly question but I've always wondered how and what the most efficient way would be.
Sam Granger is offline  
Reply With Quote
Old 11-09-2009, 06:32 PM   #2 (permalink)
The Contributor
 
Join Date: Jun 2009
Location: Seattle, WA
Posts: 76
Thanks: 1
rguy84 is on a distinguished road
Default

There is something called relational databases.

So for example, they might have a table called members, which would have a field (column) tthat has an auto-increasing number, your first, last name, an e-mail and such. From then on, you are referred to as a number. Then they have a table called status updates for example, the fields there are probably another auto-increase number, a field that refers to the number on the member table (so they know who did it), and the text of your status update.

To go further, they probably have a table called status update comments which has another auto-number, a field to reference what auto-number its referring to for the status update, a field that references the member table to know who posted the comment, then the comment text itself.

Also, a database has a 4gb limit, so it may be spread across many databases. A search wields steps to get around the limit, if needed...

Hope this helps.
__________________
Ryan | Blog | Twitter
Send a message via AIM to rguy84 Send a message via MSN to rguy84 Send a message via Yahoo to rguy84 Send a message via Skype™ to rguy84
rguy84 is offline  
Reply With Quote
Old 11-09-2009, 10:08 PM   #3 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

I think what he wanted to know was how they know which database that a certain member's wallposts are stored(for example).

Good information though, eventhough I knew all of what you wrote I'm still interested in the question I asked above.
__________________
Tanax is offline  
Reply With Quote
Old 11-09-2009, 10:24 PM   #4 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Short answer: Very carefully.

Long answer: They have networks of carefully crafted databases on many many servers. No one server could ever hope to serve that much traffic. They have exprets doing this, facebook as it is could never be created by anyone but advanced programmers. They, like all not small systems, would use realational databases. But that is just the start of it, how you relate the keys is important, more complication comes up when you have hundreds of servers trying to act as one database on the outside.

I've personally never worked with databases took up more than a single server, so I don't know too much about how they do it. Books have been written on it, I would seggust searching amazon.com for some.
__________________

Village Idiot is offline  
Reply With Quote
Old 11-09-2009, 11:07 PM   #5 (permalink)
The Contributor
 
Join Date: Jun 2009
Location: Seattle, WA
Posts: 76
Thanks: 1
rguy84 is on a distinguished road
Default

Ah ok Tanax. I would have to agree with VI. I know with access you can split the database to front and back ends. A system this big, seems to call for this. I don't know how to do that with a mysql db.
__________________
Ryan | Blog | Twitter
Send a message via AIM to rguy84 Send a message via MSN to rguy84 Send a message via Yahoo to rguy84 Send a message via Skype™ to rguy84
rguy84 is offline  
Reply With Quote
Old 11-09-2009, 11:41 PM   #6 (permalink)
The Addict
 
Join Date: May 2009
Posts: 287
Thanks: 5
adamdecaf is on a distinguished road
Default

I've heard that they have used clusters of servers (100's) that keep a large chunk of the most recent data in RAM. This would be a huge accomplishment, but I don't think that it's possible from a business side.

I would say that they separate all of the data into small clusters and sub-clusters, then those could be organized by date, predicted/actual traffic, type of data, ect.. Those sub-clusters would then have a reasonable amount of data to sift through (maybe only a few million rows), this would speed up the response and retrieval.

Again, I don't know, I'm just guessing.
__________________
My Site
adamdecaf is offline  
Reply With Quote
Old 11-10-2009, 05:01 AM   #7 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Quote:
Originally Posted by adamdecaf View Post
I've heard that they have used clusters of servers (100's) that keep a large chunk of the most recent data in RAM. This would be a huge accomplishment, but I don't think that it's possible from a business side.
It is quite possible.
__________________

Village Idiot is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
store credit card info ahlofan MySQL & Databases 7 06-12-2009 12:57 PM
Please Help, How to show upload progress information ganda Advanced PHP Programming 5 07-05-2008 07:26 PM
How do big companies like VB store passwords? Aaron General 25 04-28-2008 03:36 PM
Creating a table from loaded data benton General 5 04-20-2008 11:48 AM
Understanding the Life of a Session Wildhoney General 6 10-27-2007 02:34 AM


All times are GMT. The time now is 07:51 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design