title: Sharding on Pinterest - How exactly is was done
body: <p>I want to understand how Pinterest do their sharding according to <a href="http://www.youtube.com/watch?v=GW2cnp2tdh8" rel="nofollow">this video</a>, but can't seem to fully understand how. I'm interested because I want to apply the same strategy to my app and built sharding myself on top of Amazon RDS.</p>
  
  <p>From my understanding:</p>
  
  <ul>
  <li>They have decided to create 4096 virtual shards</li>
  <li>Several shard can be mapped to one or more physical servers. So for example you can map all shard to one server when you just starting out</li>
  </ul>
  
  <p>If I assume the following mapping table:</p>
  
  <p>Virtual Shard 1 -> 127.0.0.1</p>
  
  <p>Virtual Shard 2 -> 127.0.0.1</p>
  
  <p>....</p>
  
  <p>Looking at how they built their unique ID (Shard ID + Type + Local Auto Increment), what if I decided to add another server 12.0.0.2 because the data capacity of 127.0.0.1 is getting pretty big and I want to add more machines to increase capacity?</p>
  
  <p>How can I exactly map the shard to new servers?  I understand that data doesn't move according to the lecture, so how can they don't have hot-spots. I really can't understand how it was done, can someone give me a good step by step explanation? Thanks</p>