Introduction
Locking for Distributed Microservices
State synchronization in distributed systems is a topic that can quickly become complex. We want to abstract away as much of that complexity as possible. The Sync service is designed to help you synchronize state between your services without requiring a PhD in distributed systems.
Locking
When it comes to locking, we lock resources. A resource can have child resources. If a parent resource is locked no child resource can be locked.
We differentiate between read and write locks. While it is possible to have multiple read locks on a resource, only one write lock can be held at a time. Therefore when there is a client that holds a read lock on a child resource, no other client can hold a write lock on the parent resource. It would be possible to acquire a read lock on the parent resource though.
The Sync service uses a pessimistic locking strategy. Therefore we can guarantee that only one process can work on a concern at a time.
Tenancy
The service supports multi-tenancy, all locks within a tenant are isolated from locks in other tenants. Therefore, you must specify a tenant ID when locking.
Applications
In addition to tenancy the Sync service supports applications. As with tenancy, locks are isolated between applications. Therefore, you must specify an application ID when locking.