I noticed that Windows Azure Diagnostics uses a UTC ticks primary key as a method of making it easy to access entries by time ranges. I would like to implement a similar system for my table.

However a major issue is that the systems that will be doing the uploading will not necessarily have their time synced to the millisecond (not to mention ping time differences) so setting the Partition key locally and then uploading doesn't work well (I am having all kinds of race condition issues). Ideally I would like to guarantee that any time a table entry is made its partition key is certain to be greater than or equal to any partition key already in the table (since that's how time works).

The only way that I can think to ensure this guarantee is by having the "timestamp" partition key set server side. Is there some way to have this happen, such as via a server side script?

Note: I realize that a timestamp is added already for when an entry is made, but tables are not indexed by this timestamp.

有帮助吗?

解决方案

I would recommend using twitter / snowflake solution for that purpose. I had very similar requirement and that approach worked perfectly for me.

I used Flake ID Generator. It is .net implementation based on twitter / snowflake.

The generator can be independently deployed to different Azure instances (or work as a independent service) - I was generating ids independently on each Azure service instance. Generated 64-bit ids are directly sortable and always unique (even if come from the different instances at the same time). You also have access to its source code so you can also add customizations if needed.

I hope that will help.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top