2

I have recently been doing some research on Instagram and its API and have come across its strange file naming. Here is an example:

https://scontent-lhr3-1.cdninstagram.com/t51.2885-15/11357983_574786385995155_503550105_n.jpg

(The image is supposed to just be black...)

I understand that they used to name files like this but I cannot seem to find how they are named now. It seems random although I would like to find out if there is any pattern in how Instagram name their files. I would appreciate any information regarding this.

Community
  • 1
  • 1
rodit
  • 1,746
  • 2
  • 19
  • 33

2 Answers2

4

They explain it all in this blog post here:

https://engineering.instagram.com/sharding-ids-at-instagram-1cf5a71e5a5c

They create unique ids following a custom numbering scheme they developped such that it's 64 bits and garantees unicity:

Each of our IDs consists of:

  • 41 bits for time in milliseconds (gives us 41 years of IDs with a custom epoch)

  • 13 bits that represent the logical shard ID

  • 10 bits that represent an auto-incrementing sequence, modulus 1024. This means we can generate 1024 IDs, per shard, per millisecond

If you want an implementation example, the blog post explains it pretty well but since the original questions is not about how to get the file name rather than where it comes from I feel the above quote to be sufficient.

Sebastien
  • 1,439
  • 14
  • 27
  • 1
    A link to a solution is welcome, but please ensure your answer is useful without it: [add context around the link](//meta.stackexchange.com/a/8259) so your fellow users will have some idea what it is and why it’s there, then quote the most relevant part of the page you're linking to in case the target page is unavailable. [Answers that are little more than a link may be deleted.](//stackoverflow.com/help/deleted-answers) – Papershine Feb 15 '18 at 02:43
  • @paper1111 In this case, I'm not sure anything short of importing the entire article would make sense. I'm inclined to allow it. – ceejayoz Feb 15 '18 at 02:44
  • @ceejayoz If a question here can't be answered properly without linking to an external resource, the question is very likely far too broad. – Rob Feb 15 '18 at 02:59
  • The question was bad in the first place and I decided to post the blog post because I was tired to stumble on this page rather than the blog post. Google search is now poluted with bad SO questions with equally bad answers... – Sebastien Feb 15 '18 at 03:33
  • And someone will have to explain to me why linking to another SO answer is ok but linking to another source's answer is not. – Sebastien Feb 15 '18 at 03:35
  • @Sebastien StackOverflow links can be reasonably assumed to still be available in a StackOverflow answer because if they turn into 404s the question will be gone too... – ceejayoz Feb 15 '18 at 13:40
-3

Best guess is they use random. It's Javascript so they probably have a random set of numbers generated to avoid data corruption.