educative.io

Photo key generation is not scalable

hi @Design_Gurus

generation of photo id using epoc is not scalable. You are putting all load on a single db and since there will be lot of photos we need to have multiple instances of db both serving requests, but it is not possible the way u did because if u add one more db ,and let us say one generate even and one generate odd, then u loose the time sorting criteria. If u need to have it sorted by time then this approach is not scalable as we are forced to use one db for generating auto sequence. The only option is to create index on creation date

Even actual insta does that…
https://instagram-engineering.com/sharding-ids-at-instagram-1cf5a71e5a5c

I think Author read this blog before writing this post. They didnt take important part from it.