Say for example I was running a popular image host and all my images have an ID which they can be accessed by. If I wanted this ID to be sequential and not random what would be the best way to make sure two images uploaded at the same time don't get assigned the same ID by different processes/servers.
The best way I can think of is having different processes reserve a block for example one might reserve 1-1000 and the next one could reserve 1001-2000 so the IDs would never clash.
What is the best solution to this problem and how is it usually solved. It seems like most sites use a random ID. Is there a reason for this?