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.
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.