How are node IDs generated?
{nid} is an auto_increment field in the table {node} - As all of the nodes are sourced from that one table it's able to keep its serialization. This is part of why UUID is such an important initiative in Drupal 8. It's not straightforward to maintain portability of content across environments for this reason.

The type is int(10) also known as unsigned so you're only limited by the data type limit of your preferred database and the disk space on your database server to store all those nodes. If it's MySQL that's 0 up to 4294967295.