DynamoDB auto incremented ID & server time (iOS SDK)

后端 未结 3 1651
既然无缘
既然无缘 2020-12-20 13:12

Is there an option in DynammoDB to store auto incremented ID as primary key in tables? I also need to store the server time in tables as the \"created at\" fields (eg., user

3条回答
  •  佛祖请我去吃肉
    2020-12-20 13:59

    Rather than working with auto-incremented IDs, consider working with GUIDs. You get higher theoretical throughput and better failure handling, and the only thing you lose is the natural time-order, which is better handled by dates.

    Higher throughput because you don't need to ask Dynamo to generate the next available IDs (which would require some resource somewhere obtaining a lock, getting some numbers, and making sure nothing else gets those numbers). Better failure handling comes when you lose your connection to Dynamo (Dynamo goes down, or you are bursty and your application is doing more work than currently provisioned throughput). A write-only application can continue "working" and generating data complete with IDs, queueing it up to be written to dynamo, and never worry about ID collisions.

提交回复
热议问题