Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook photo renaming convention

When we upload any photo to Facebook it is renamed by Facebook. The new name generally has the following pattern: 393268_10151029983750034_598680033_21778114_899520598_n.jpg

This name can be split with underscore in 6 parts.

  1. I know that the second number in the name is the fbid of the photo and you can access the photo directly in Facebook with: https://www.facebook.com/photo.php?fbid=10151029983750034 provided you have the necessary permissions.
  2. The third number is the Facebook profile id of the uploader of the photo. You can go to the profile of the uploader by: https://www.facebook.com/profile.php?id=598680033

I have the following questions regarding this naming convention:

  1. Does anyone know what other information is present in the name of the photo? Is the information about the shards/node/bucket to which the photo belongs present in the photo name?
  2. What are the advantages/disadvantages of such a naming convention?
like image 983
dsr Avatar asked Feb 26 '12 03:02

dsr


1 Answers

I don't really know how exactly they handle this naming scheme, but I suspect it has to do with their storage.

Facebook uses a database named RocksDB, on top of a MySQL fork (Created specifically for this database), which is called MyRocks.

They used MySQL until 2012, but then switched to a No-SQL type of because of their 'unique needs'.

RocksDB can only store key-value pairs, and then the data structure must be adapted for this, hence, if you cant have the user's ID in a table, and the photos belonging to that user in other, they can be bound via normalization, which in this case prioritizes speed over storage size.

The advantage of such a system, would be speed, as you save the overhead of a traditional join by calculating beforehand the exact name of every piece of data you want to query.

like image 53
Baruch Spinoza Avatar answered Sep 28 '22 07:09

Baruch Spinoza