title: How to build REST API with server-defined ids?
body: <p>This is a classic RESTful way of creating resources I have in the application:</p>
  
  <pre><code># This creates user. Client is responsible to create UUID, which is simple
  PUT /users/CLIENT_GENERATED_UUID
  # Access user by uuid
  GET /users/UUID
  </code></pre>
  
  <p>When we touch the field of data storage performance it turns out that randomly generated UUIDs do not serve well by many reasons like data locality.</p>
  
  <p>Server-generated IDs are good for performance but they don't really match REST:</p>
  
  <ol>
  <li>If you use POST to create resources, you lose idempotency: PUT, GET, DELETE idempotency is implied by REST, while POST is not.</li>
  <li>You may ask server to provide you with a nice ID before doing PUT. Despite it feels quite heavy and non-obvious, it also does not protect from dummy client that uses own random id instead of asking for it.</li>
  </ol>
  
  <p>Could somebody give me a hint in this architecture matter?</p>