Archive for December, 2011

Underneath Facebook

A myriad of us spend a considerable amount of our free time on one site, Facebook. A few others might spend all their time, and there are a few who have already spent a lifetime. All of us know Facebook as how it appears from the outside. All information in our profile, wall, albums and pages, beautifully rendered in that blue and white layout. Friends. Photos. Status Updates. Comments. Likes. Videos. Apps. Games. Everything under one platform. Facebook has evolved to that point where it in itself has become as much a phenomenon as the whole Internet is.

For how it has become very much a part of our lives, it would do some justice for us to know a bit about how things work underneath.

I have been interning at this startup called QuiKast for the past two weeks, and as a part of my project over there it was required that I learn about Facebook. So while what I talk about in this post will no way be related to programming and development, I sure will come back with a post talking about a Facebook app. But now, let’s get to the Facebook Graph.

Now for all the people who don’t know what a graph is yet, a graph is a set of nodes connected by edges. The general representation of anything in a graph is with ‘objects’ acting as nodes, and the ‘relationship’ between two objects acting as an edge. I think that describes it in a fairly simple and concise manner.

Here is how things work. ‘Facebook’ is a graph. The whole of it. To some such a perception would sound absurd. But that’s how things are. Everything in Facebook is an object. Every piece of anything on Facebook is an object. You are an object on the Facebook graph. Your friend is an object on the graph. Your status update is an object of its own. Your photos are objects of their own. And what holds them together is the relationship between them, the edges, except that there are different kinds of relationships between different objects. The relationship could be something like ‘friend’, or something like ‘like’, or ‘tag‘, or ‘own’, or anything else you could think of. Probably this image is going to help you with the visualization.

Facebook Graph

That sure does make things a lot easier to understand. So Facebook identifies and knows certain kinds of relationships as I told you about. And the objects that interact can be virtually anything. Of course, it knows of people, pages, groups and apps but whatever it is, is a property of the object. And whatever the object is, is given an unique identifier. The object of my profile on Facebook has the ID 559736373. And the object of Mark Zuckerburg has the ID 4. The Facebook ID of the official page of Adidas is 182162001806727. And the ID of the Texas HoldEm Poker app is 2389801228. Now here’s what happens when I go and like Adidas. An edge is drawn between 559736373 and 182162001806727. And the relationship that describes the edge is ‘Likes‘. Suppose I upload a new photo. It is given a new identifier. And then there’s a relationship ‘Photo From‘ between myself and the photo. And then I tag a couple of my friends in it. Two new edges are introduced into the graph. Between each of my friends and the photograph. By the relationship ‘Tags‘. Even external objects residing anywhere on the internet is mapped onto the graph once it starts interacting with Facebook. Take for example the “Like” box that you see on the top right corner of this site. The first thing that happened when I added the “Like” box was that Facebook created an object for ‘’. Now the moment someone likes it, a new edge is drawn between them and this site.

I think we’ve come one step down now. It makes more sense to get looking into things with a more hands-on approach. Let’s start exploring the Facebook Graph. Externally. Not from within Facebook. Let’s visit And please do this through Firefox or Google Chrome. What do you observe? There you see the object of the page Internet Society. Now this is an object, and it has some attributes which you can see from the graph. These attributes are properties of that object. Now try That’s me.

Okay. This doesn’t seem to define all of me properly, does it? It doesn’t show all the details that you see in my profile, does it? Nope. There is more to my profile. I link to different objects. The different things that define me. My wall posts. My photos. My friends. And everything else. It is very much possible to view them all through the graph. Say you want to check all my friends. And the music that I like. Well, I know this didn’t work. You need something called an access token to view my profile details. Then the URL would become something like This isn’t really a valid access token. I can give you an access token, but then it would expire in a while and wouldn’t work if you try. I would rather go with screenshots. You can view my friend list here. And the music that I like here. Observe that each music band that I like and each friend of mine has an unique ID, and also check out the awfully long access token on the URL. Likewise you can access just about any detail of mine, anything like a photo or any of my wall posts, using an access token. You would have to go to /photos or /feed or /groups or /videos or /likes or other relationships. And you would require an access token to access any of these, because that’s how my privacy settings are. Within Facebook, when you click on my profile, you get to see all these details, but that’s because being a friend, Facebook internally gives you access privileges and then you make a request to view my details. And say when you visit the profile of someone who is not a friend, then Facebook does not give you privileges to view his posts or photos. It’s all about privacy.

Let’s jump into a photo that is public and can be viewed by anyone. Check this out. If you can follow the braces, then you’d get the real feel of the graph. You can see the “from” tag which gives the owner of the photo. You can see the names and IDs of the people who have been tagged in it, who have liked it, who have commented on it. You can even check out the comments in the “message” tag. Note that every comment also has its own ID. And not to forget, you can check out the link of the photo under “images:source”, the URL where it really resides on the web.

And you can see that Facebook is a lot about traversing through these graph structures, generating them, and rendering the right content at the right place. But it’s one messed up graph, and what seems simple isn’t really all that simple. Mad coding, defining Data Structures that can handle these, and continuous optimization runs behind the scenes.

I think we’ve come to an end here. I really appreciate it if you read through the whole thing. It sure is good to know more about something you are passionate of. I tried to be as descriptive as possible, but I can’t be telling that I explained the whole of it. There’s always more to learn, and best way to do is to visit the Developers page in Facebook and start reading up on things. However, I’m sure this would have given you a good insight into how things are ‘Underneath Facebook’.


The Inception

Turns out that I can be the subject of a stereotypical Rajnikanth joke. “Rajnikanth’s email address is”. Well yes, now my email address is You might think of me to be a person too self-obsessed, about me owning a domain with my own name. But then this is a personal website, and an address like is far more sensible and better sounding than something like or And moreover I couldn’t have purchased such a domain ’cause there already must be a dude with that address.

Well, but why did I even want a website in the first place?

Now I needn’t be reasoning, but then I can’t think of anything else to be writing as my first post in this blog. So here goes. Because I needed one. I needed a reliable hosting space, and I landed up with this domain. Of late, I have been into developing a few simple text based mobile applications which use the response of my PHP applications hosted on a server. And also I have been into developing websites, testing them on random sub-domains around the web. At first I did resort to free hosting sites as anyone would. But I’ve had my bad time with them. Uptime is horrible. And the FTP bandwidth is terrible. The kind of restrictions that they can impose on free users is limitless. And unpredictable. Who bothered to read through their Terms and Conditions? But then it’s a free hosting account, and I shouldn’t have expected more. The response that I used to get from my hosted applications on access was so erratic. And they wouldn’t work over considerable times in a day. And then one day, on login, I got this message. “Your account has been suspended for violating 20%+ CPU usage limit for more than 1000 times”.

Boom. Everything on it was lost. And the applications which it used to feed stopped working. “Upgrade to Premium Hosting”. That’s what they said. I should have understood when I saw the Free vs. Premium Hosting comparison table on the homepage. A ✓ would disgracefully find its seat in between a majority of ✕. And look at the other side. A row of majestically aligned ✓.

Well it was time to think about switching to a paid hosting service. And thanks to my dad, he agreed. But then I chose a new webhost. Reliable, hopefully. And now I’m here. And the domain name? I can’t be hosting things on an empty cloud. And if I do, nothing can ever point to them. It needs an address.

Welcome to This is it. I do not have a definite idea in mind as to what I’m going to be using this website for. But it’s a good time to start blogging, and to play around. I cannot promise to be regular blogger, but then I think there is a bit of enthusiasm in me that’ll show up for the first few months.

I’m calling it “Bits and Bytes”.

Copyright © Bits and Bytes | Arjun Abhynav. Powered by WordPress.