nats.io - How to use NATS KV for distributed locking - Stack Overflow

admin2025-04-17  4

I am planning to use the key-value store provided by NATS to implement a distributed locking mechanism. The KV provides "create" method which suits my need.

I am planning to run NATS in a clustered environment. If my understanding is correct then if I create KV in a replicated manner, NATS will use quorum to ensure that the write has been propagated to majority of the nodes. I am trying to keep the write speed to a minimum and would like to skip the extra synchronous writes.

I intend to write the data to KV on a single node and would like that data to get replicated to other nodes asynchronously for fail-over. Considering all read/write goes through the same node I should still be able to achieve strong consistency.

Is there a way to change the way NATS KV replicates the data?

Kind Regards,

转载请注明原文地址:http://anycun.com/QandA/1744899494a89200.html