title: Good algorithm for unique random generation of IDs
body: <p>I need to generate a random ID, alphanumeric, 6 characters, as the ID for shortlink service.</p>
  
  <p>Currently, I generate a random 6-character code, look up in the db to see if it has been used before, and if it has, repeat the process. I need it to be unique for all 36^6 combinations. As the system grows, the worse its performance.</p>
  
  <p>Is there known good approach that minimizes hitting the db, preserves state globally, and will not take more than 100ms to lookup?</p>
  
  <p>Thx for any help</p>