Search code examples
amazon-web-servicesgremlinamazon-neptune

Gremlin PartitionStrategy PartitionKey vs WritePartition


I have a question about partitionStrategy

const strategyA = new PartitionStrategy({ partitionKey: '_partition', writePartition: 'a', readPartitions: ['a'] });
const strategyB = new PartitionStrategy({ partitionKey: '_partition', writePartition: 'b', readPartitions: ['b'] });
const strategyC = new PartitionStrategy({ partitionKey: '_partition2', writePartition: 'b', readPartitions: ['b'] });

All 3 of these are "separate". I notice that data is first split on partitionkey, then the partition itself. I can read from partition A, and I'll receive the same data as long as the partitionKey is the same.

In my mind this is used sort of like

partitionKey = clientID writePartition = ['uat', 'prod', ...]

However if I only need a 1-level key, it seems better to use separate partition keys for more guaranteed separation.

Is my understanding correct or is there some other reason partition strategy has both key+partition?

Thanks


Solution

  • The partitionKey is only meant to specify the name of the property key in which to store the partition value. Perhaps a better name might have been "partitionKeyName" as that is more descriptive of what it's real usage is.

    Generally speaking, you would have the same partitionKey for the entire graph. It's an interesting idea that you have where you could could effectively create wholly independent partitions by specifying multiple partitionKey values for the same graph. But then you are making partitions based on existence of a particular key on a graph and you would never be able to traverse the graph as a whole with PartitionGraph.