How does Amazon generate its order number?

Note. I already read older questions, such as What is the best format for customer number, order number? however my question is a bit more specific.

The generation of pseudo-random numbers in the near future meets with the "birth problem". For example, if I use a 27-bit field for my order number, after 15,000 entries the chance of collision increases to 50%.

I am wondering how large e-commerce businesses such as Amazon generate their order number in any other way - for example:

  • pre-generate the entire set and select from them randomly (several hundred GB of database)
  • Use lexicographic "next_permutation", starting with a certain number of seeds
  • MD5 or SHA-1 hash of date, user, etc. parameters truncated to 14 digits
  • etc.

All I want is a non-repeating integer (it doesn't have to be very random, except to obfuscate the total number of orders) of a certain width. Any ideas on how this can be achieved?

+4
source share
1 answer

Suggest starting with a date in reverse format, starting at 1, and then using a check (or random) digit. If you are likely to never exceed 100 orders per day, you need to add two digits plus a check / random digit.

Only the last two digits should be included per year, only the last digit is possible, depending on how long you keep order records: usually 7 years is enough, that is, records from 2009 (starting from 9) can be deleted in 2018 during to reuse order numbers in 2019. You can use mmdd for the next 4 digits or just indicate the number of days in a year and use only 3 digits - it depends on how much you want the person to be human. It is also possible to simply omit the day of the month and restart consecutive numbers at the beginning of each month, rather than every day.

Today is November 2, 2017, suppose today it is order No. 16, your order will not be 71102168 (where 8 is a check digit or a random digit). If you are likely to reach, but do not exceed a thousand, you will need an additional digit, thus: 711020168. To avoid limiting the number of digits, you can use a hyphen: 71102-168 ... you may include another hyphen before checking / random digit, if you want: 71102-16-8.

If you have several areas related to orders, you can include a depot number, perhaps at the beginning or after the date, which allows you to use serial numbers in each depot - for example, depot 5 can be: 5-71102 -168, 71102- 5-168 or 711025168. Again, if you do not use hyphens, you will need to evaluate whether you need up to ten, hundreds or thousands (etc.) of possible depot numbers. Hope this helps!

+1
source

All Articles