views:

44

answers:

1

Hi! I'm rather confused right now about exactly how many unique ids MongoDB could generate for a single server.

Of course, with multiple servers the server section of their id object would change too, but with a single server the only parts that would change seem to be the pid section (2 digits) and the incrementing section (4 digits). Correct me if I'm wrong about this.

With only 6 of what appear to be hexadecimal digits changing, I am pretty sure that there will be only 16,777,216 possible combinations for a single server.

The reason I am asking this question is because I am considering using MongoDB to store billions of unique records, and the number would continuously grow.

Is it safe to use MongoDB for this type of job? I'm sorry if I'm made any mathematical errors or logical errors.

Thanks!

+2  A: 

You should be safe. If you're getting MongoDB itself to generate ids, it'll generate a 12-byte value, of which 4 bytes are seconds since epoch, and 3 bytes are counter. This is sufficient for more than 7.20 * 10^16 (i.e. 2^(7*8)) documents per server, and/or 16 million (i.e. 2^(3*8)) per server per second.

mjs
Thank you very much for the help! I doubt I'll ever run out of unique ids in that case. ;)
Jonathan Chan