Stories
Slash Boxes
Comments

News for nerds, stuff that matters

Slashdot Log In

Log In

Create Account  |  Retrieve Password

How Facebook Stores Billions of Photos

Posted by CmdrTaco on Wed Jun 25, 2008 09:57 AM
from the laser-printer-and-a-warehouse-i-figure dept.
David Gobaud writes "Jason Sobel, the manager of infrastructure engineering at Facebook, gave an interesting presentation titled Needle in a Haystack: Efficient Storage of Billions of Photos at Stanford for the Stanford ACM. Jason explains how Facebook efficiently stores ~6.5 billion images, in 4 or 5 sizes each, totaling ~30 billion files, and a total of 540 TB and serving 475,000 images per second at peak. The presentation is now online here in the form of a Flowgram."
+ -
story

Related Stories

This discussion has been archived. No new comments can be posted.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More
Loading... please wait.
  • by denzacar (181829) on Wednesday June 25 2008, @10:00AM (#23935047)

    I thought it was created just so that you could have all your spam and silly forwards in one place.

    • by oskard (715652) on Wednesday June 25 2008, @10:49AM (#23935831)
      I think you're thinking of MySpace.

      If you used the service, you'd know that Facebook privacy settings are actually implemented very well. For example, I set up an account for my mother so she can look at all her siblings photos. She hasn't been bothered by anyone outside of the family, and is really enjoying the ability to communicate with everyone.

      The best thing I can compare it to is AOL. Its got a built in Email clone, IM service, Forums, Groups, and of course, profiles. But unlike AOL, Facebook is just a web page. There's no lock in - its more of a resource provider than a service provider.
      • I find it funny that you start by defending FaceBook from the following statement:
        I thought it was created just so that you could have all your spam and silly forwards in one place.

        Then proceed to futher prove the GP post by saying:
        The best thing I can compare it to is AOL
      • by vux984 (928602) on Wednesday June 25 2008, @02:43PM (#23939585)

        If you used the service, you'd know that Facebook privacy settings are actually implemented very well.

        Given that I can't look at my sisters photos without signing up for an account I'd say her privacy is being 'protected' solely to induce all her friends and siblings to sacrifice theirs by joining facebook.

        I set up an account for my mother so she can look at all her siblings photos.

        You don't need facebook for that.

        and is really enjoying the ability to communicate with everyone.

        or that.

        But unlike AOL, Facebook is just a web page. There's no lock in - its more of a resource provider than a service provider.

        How exactly is requiring me to create and login to a facebook account to view content someone else wants me to be able to see not lockin?

        That's like requiring me to create a gmail account to receive email from people with gmail accounts. Or requiring me to sign up to AOL to see websites hosted by AOL. Facebook is pretty much the definition of lock-in.

        • Re: (Score:3, Interesting)

          I'd need to test it again, but I'm fairly certain FB had a function that let you share albums with non-users by having FB generate a special link you'd give to the user.

            • Re: (Score:3, Interesting)

              I would consider a social networking product if one existed where I was the customer not the product.

              Sure, that's a nice idea. But of course then you're paying for it, and most likely so must all your friends and family if they want to share its best features with you. I think a social network built on that model would not grow large. It might fill a niche, but it would have nowhere near the utility of a free-to-join network that promotes sharing information.

              What makes a social networking site really gre

              • Re: (Score:3, Interesting)

                Sure, that's a nice idea. But of course then you're paying for it, and most likely so must all your friends and family if they want to share its best features with you.

                Lets see, my ISP offers 'free' email, pop3, imap, and webmail access. They offer 'free' access to a reasonable number of usenet groups, and offer a small and fairly limited but entirely usable web hosting package, with tools to make it easy to setup multiple small websites, upload and share photos, and so on.

                Is it really 'free'? Of course not

                  • Re: (Score:3, Interesting)

                    I haven't used my ISP's mail since I lived on campus back in college. Before I got there, I did not use my dialup ISP's email service. Two reasons: a) email address lock-in; b) the interface sucks.

                    re: a - the same applies gmail or any other provider.
                    re: b - there was likely no 'gmail' when you were 'back in college on your dialup isp', and most people used standalone clients, many still have little need for webmail.

                    Nowadays I've solved the lock-in problem by paying for a domain

                    makes sense.

                    and the sucky int

              • Re: (Score:3, Interesting)

                It's nice to have principles but at the end of the day my friends come first. I can always (ad)block adverts. Oh no, what if they wheedle into my subconcious or the ToS change? Then I'll occasionally make a marginally worse purchasing decision. It's not like i never do that anyway.

    • by 0100010001010011 (652467) on Wednesday June 25 2008, @11:19AM (#23936349)

      This stuff is cool either way, even if it is just "childish spam." Many of us only dream to work on something that will become this large scale.

      Facebook started off (stolen idea or not) as a site with some php and a database. In the early years there were no applications or photos. They've managed to scale PHP beyond what most slashdotters will say PHP can even do. They've even contributed some of their stuff back to the PHP community. [facebook.com]

      Look at some other similar 'home grown' sites that have had to quickly scale and invent stuff just to stay a float.
      Archive.org has their pentabox [archive.org]
      Google has their Google File System [google.com] and all of their own hard ware design.

      Hopefully the site will recover. 540TB of data and 500k images per second while at the same time being able to process photos near instantly in the background to 4-5 different sizes is nothing to ignore. Fortune 500 companies could probably learn a thing or two...

      • Already been done. (Score:5, Informative)

        by sirrube (622137) on Wednesday June 25 2008, @12:01PM (#23937089) Homepage

        This stuff is cool either way, even if it is just "childish spam." Many of us only dream to work on something that will become this large scale.

        ...

        Fortune 500 companies could probably learn a thing or two...

        This Fortune 500 company could teach a thing or two on this subject. [datatree.com] Since before 1999 DataTree has already did this. With over 40 billion land records online, and 600+TB of data, they deliver many millions of images daily. Not to put down FaceBook's Implementation, but DataTree does not need to run 10k webservers and 1800 SQL databases to provide images. It is nice to see the scalability factor of their design, but it does not mean that it is the most efficient way to do things, or to follow and learn from.
    • That's Digg -- "Hey look at this cool link I found."

      Facebook is where you spam your friends with pointless messages about how you've hurled a squirrel at them.
  • But seeing as how this just got posted and already it's Slashdotted, I'll bet it's not the same way Flowgram stores its presentations.

    • Re:I dunno. (Score:4, Informative)

      by aproposofwhat (1019098) on Wednesday June 25 2008, @10:28AM (#23935497)
      Not only that, but the UK Facebook site has been down most of the afternoon - some infrastructure, huh?
      • Re: (Score:3, Informative)

        To view the slideshow . . err I mean 'flowgram' (whatever the fuck that's supposed to mean), you dont need to register.

        • Re:I dunno. (Score:5, Insightful)

          by 7 digits (986730) on Wednesday June 25 2008, @02:16PM (#23939203)

          In the late 90's we stopped using documents with images and text), because they had the following disadvantage:

          1) Printable
          2) Searchable
          3) You could look over them at a glance to find information

          We replaced them by the fabulous presentation with voice-over.

          It removed part of the ability to scan over information, to search, and to print.

          Unfortunately, it still had the disage of letting the user seek to some part of the presentation, so another iteration was needed.

          Now, welcome to the 21th century. Thanks to flowgram, you don't have to worry about printing anymore (you can't), or searching (you can't), or even pausing, going forward, or doing anything (you can't).

          If you get a phone call in the middle of the presentation, though luck. And of course, you have no way of knowing how long it is, how long is left, or anything. And if you miss a word or a sentence, you can always restart the presentation and listen more carefully the next time.

          I must congratulate the folks over flowgram.com. It seems very hard to have some idea that could be less usable. I'm pretty sure there is someone somewhere working hard at this, and some VC will give him money for that, but, for now, if you want to put have a shitty unusbale presentation online, flowgram is the way to go.

  • by Anonymous Coward on Wednesday June 25 2008, @10:04AM (#23935099)
    Ohhhh boy, queue the pr0n jokes in 3... 2... 1...
    • Ohhhh boy, queue the pr0n jokes in 3... 2... 1...

      Cue the cuneiforms of cute girls with no acumen queuing up to watch Cusack's cucumber

      Cheers!
      --
      Vig

  • by OglinTatas (710589) on Wednesday June 25 2008, @10:12AM (#23935231)

    at Flickr

  • FLASH?! (Score:4, Funny)

    by T-Bone-T (1048702) on Wednesday June 25 2008, @10:13AM (#23935259)

    "You either have javascript turned off or you have an older version of Adobe Flash."

    That was an informative article but I didn't see anything about Facebook. At least there weren't ads and they kept it to one page!

    • Re: (Score:2, Informative)

      I do have Javascript installed, and am running Adobe Flash (Linux version). Doesn't work :(
      • They should teach Firefox and Opera how to play video directly. It's not much harder than displaying an image file.

        • Re: (Score:3, Insightful)

          I think it's becoming part of the HTML5 spec; however, it's tremendously more complicated due to the limitless plethora of video formats. With web-oriented images, it's almost all jpegs for photos and typically pngs for graphics, with plenty of gifs around. Tiff is a very established format but never sees use in websites since the files are stupidly large, and most other formats are specific to some editing program. With video, you've got half a dozen Quicktime formats, DivX, XviD, h.264, x264, WMV, Real

  • Very interesting (Score:3, Informative)

    by phase_9 (909592) on Wednesday June 25 2008, @10:17AM (#23935331) Homepage
    Fascinating Presentation for those of you who actually bother to watch the Hour or so of content.
  • Slashdotted (Score:5, Funny)

    by Rik Sweeney (471717) on Wednesday June 25 2008, @10:22AM (#23935415) Homepage

    Does anyone see the irony in Flowgram's demonstration?

    Flowgram Guy 1: "OK, this is how Facebook stores billions of photos and serves thousands of them each second"
    Flowgram Guy 2: "Cool, maybe we should implement that technology"
    Flowgram Guy 1: "Why? It's not as if we're ever going to have our servers swamped with thousands of requests..."

    • Re: (Score:2, Insightful)

      That's for sure.

      Plus, when their server (singular?) finally responded to me, it requires a later version of Flash than I have. So I can't read the presentation at all. Way to not get the word out, folks.

  • by vigmeister (1112659) on Wednesday June 25 2008, @10:29AM (#23935503)

    Let's all go look at pictures on fb from 12 noon EST to 12:05 EST. That ought to show them...

    I 3 Myspace hunni!

    Cheers!

  • Transcript? (Score:5, Insightful)

    by dstar (34869) on Wednesday June 25 2008, @10:42AM (#23935715)

    I don't suppose there's a transcript of this anywhere, is there? That + slides would be infinitely more useful....

  • by bucky0 (229117) on Wednesday June 25 2008, @10:54AM (#23935917)

    I wish that facebook wouldn't resize its images on the backend. My friends all post pictures from parties/trips, etc.. there, and I'd love to be able to just download the full res version to send off to be printed, but facebook resizes the largest dimension to be ~600px, which is pretty worthless for printing.

    Yeah yeaj. there's other sites that don't, and I post my stuff there (to flickr, personally), but convincing that one person who took the nice photo of you to do it too is near impossible.

    • Re: (Score:3, Informative)

      Get the Big Photo [facebook.com] application.

      It's not ideal, but it works quite well. A friend of mine is a professional photographer and she puts all her work up there. Works well for her.
  • by Ralph Spoilsport (673134) * on Wednesday June 25 2008, @10:59AM (#23936011) Journal
    equals about 18k per image?

    RS

  • Not hard (Score:5, Insightful)

    by mlwmohawk (801821) on Wednesday June 25 2008, @11:21AM (#23936377)

    While the article is slashdotted, this is not a hard problem. It has an expense involved, but it is not difficult.

    So, as another poster implied, 18K per photo on average, so about 8Gig per second, peak.

    So, assuming that the pictures are evenly distributed, you'd need a bunch of machines and a good number of "tubes" and a way of directing requests to the correct image server or server cluster.

    So, what's the problem? Why would you think this is difficult? It's all off the shelf technology, just a bunch of it.

    • I find (Score:5, Insightful)

      by msimm (580077) on Wednesday June 25 2008, @12:06PM (#23937149) Homepage
      That if you plan to do it (or hope to) it helps to read the ups and down of people who already have. And it's *nice* that some take the time out (as ./ did and a number of other sites) to talk about it so that we can learn from their experience and mistakes.

      But if you already know everything, by all means, shoot. But the outline that just got you modded as insightful isn't an application, didn't detail redundancy of any sort and would be a management nightmare (ie, all the interesting stuff).

      I mean really, we could propose that solution to just about any web based application but that's not hardly the story is it?
    • by Anonymous Coward on Wednesday June 25 2008, @12:08PM (#23937195)
      Limits, like: Netap filers max out at 16Tb (raw) per volume, so you have to start using multiple volumes and get creative with mount points and hope you dont hit some other limit (max files/inodes, addressing limits of the os/fs, etc). The harder part is the "way of directing requests to the correct image server/cluster" you mention. Its not quite "off the shelf" technology, as you now have to implement something that can handle the 4750000+ requests per second and point them in the right direction for a single entry in a pool of 30000000000. And thats just images, you still have to route and serve the rest of the content for the pages. At those levels, a simple F5 load balancer is not going to cut it. Stacking a bunch of F5's still wont do. This will probably be distributed across several DCs stretched across distant geographical areas with some DNS magic to route traffic to locally close DCs. Keeping even the indexes in sync so the requests can be rerouted to the proper DC (if not stored locally) becomes an interesting problem to solve.

      No, I dont work for them, but I do work for another company facing similar storage/distribution problems. When things get this big, its not simply "take what works and just make it bigger or get more of them", you have to start redesigning things. For a bad car analogy: its like saying a passenger train is just a bunch of greyhound busses.

      tm

    • Re:Not hard (Score:4, Interesting)

      by funbobby (445204) on Wednesday June 25 2008, @12:38PM (#23937671)

      The issue isn't the number of bytes per second, it's the number of distinct requests. The data is _way_ bigger than will fit in memory, and hard disks can only do 100-150 seeks per second so you need a lot of them to serve from disk. A naive implementation will go to disk many times for a single file, because filesystems aren't designed for this many small files. So this is really an issue of getting exactly the right stuff in memory so you can serve hot content from memory, and if you go to disk you seek exactly once instead of several times.

  • Akamai? (Score:3, Insightful)

    by ruiner13 (527499) on Wednesday June 25 2008, @11:26AM (#23936493) Homepage
    Why don't they just use a 3rd party distributed storage system like Akamai NetStorage [akamai.com]? Then they don't have to worry about adding capacity, redundancy, etc. All they have to do is upload the picture there, and Akamai mirrors it all around the world.
    • Re: (Score:3, Informative)

      by Anonymous Coward

      That won't work considering the number of files. Given the quote (which require nearly a year of hassle with the Akamai morons and sighing an NDA, thus the AC post) we got from those idiots, it would cost us almost $200k/year given our bandwidth use to store ~1,000 files. Facebook has 30 billion files and assuming the same price per file as we were quoted, Akamai would charge $6,000,000,000,000/year to host them. To put that number in perspective, that's more than the GDP of the Germany plus that of the

  • by debest (471937) on Wednesday June 25 2008, @11:49AM (#23936889)

    I put some short video clips on Facebook's video application (just stuff of my daughter for my friends and family to see). These are AVI files generated by my digital camera, about 20-30MB in size, lasting about 1-1.5 minutes each.

    They uploaded pretty quickly, but then they were put in a queue to be encoded for their flash player. It took over 3 days for them to be online in my profile! It seems they don't need to just have large capacity for storage, but a bunch more CPU for processing.

  • Next paper (Score:5, Funny)

    by apillowofclouds (699564) on Wednesday June 25 2008, @11:58AM (#23937027)
    Next article, how to effectively serve a Flowgram that's referenced on Slashdot
  • by electricbern (1222632) on Wednesday June 25 2008, @01:52PM (#23938803)
    Simple: 70 thousand pen drives.
  • User-mode GoogleFS (Score:5, Informative)

    by Panaflex (13191) <convivialdingo@@@yahoo...com> on Wednesday June 25 2008, @02:53PM (#23939753)

    (summarizing the big long presentation)

    This is basically want to make a usermode GoogleFS. Their biggest problem is reducing reads - which are hampered by Posix file standards (inodes, metadata, etc...)

    Instead they use a database-like index/data file arrangement. The index stays in memory and files are stored together in large contiguous spaces on a single file. It's possible to utilize a LUN for storage - but not there yet.

    There... where's my cookie?

    (Oddly enough - I'm writing the exact same code they are... bazaar world, eh??)