Skip to content

Commit 81d401a

Browse files
committed
Add more links on leases and locks
1 parent ec6d1d3 commit 81d401a

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

README.rst

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,11 @@ coordinating Machine IDs in your deployment.
139139

140140
Task is not trivial, but neither is impossible. Here are a few ideas:
141141

142-
* Coordinate ID assignment via something like etcd_ or ZooKeeper_ using lease_
143-
pattern. Optimal, but a bit bothersome to implement.
142+
* Coordinate ID assignment using:
143+
* Lease_ pattern (etcd_, ZooKeeper_)
144+
* Distributed locks:
145+
* Redlock_ (Redis_, Valkey_)
146+
* Advisory locks (PostgreSQL_, MariaDB_, etc...)
144147
* Reinvent Twitter's SnowFlake_ by having a centralized service/sidecar. Extra
145148
round-trips SonyFlake intended to avoid.
146149
* Assign Machine IDs manually. DevOps team will hate you.
@@ -174,10 +177,15 @@ should figure out on your own. Here's some numbers for you to start
174177

175178
.. [#] 1409529600 + 0x874AD4993 / 100 = 2026-03-05T09:15:19.87Z
176179
.. _UUIDv6: https://www.rfc-editor.org/rfc/rfc9562.html#name-uuid-version-6
177-
.. _etcd: https://etcd.io/
178-
.. _ZooKeeper: https://zookeeper.apache.org/
180+
.. _Lease: https://martinfowler.com/articles/patterns-of-distributed-systems/lease.html
181+
.. _etcd: https://etcd.io/docs/v3.6/tasks/developer/how-to-create-lease/
182+
.. _ZooKeeper: https://zookeeper.apache.org/doc/r3.9.5/recipes.html#sc_recipes_Locks
183+
.. _Redlock: https://martin.kleppmann.com/2016/02/08/how-to-do-distributed-locking.html
184+
.. _Redis: https://redis.io/docs/latest/develop/clients/patterns/distributed-locks/
185+
.. _Valkey: https://valkey.io/topics/distlock/
186+
.. _PostgreSQL: https://www.postgresql.org/docs/current/explicit-locking.html#ADVISORY-LOCKS
187+
.. _MariaDB: https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/miscellaneous-functions/get_lock
179188
.. _SnowFlake: https://en.wikipedia.org/wiki/Snowflake_ID
180-
.. _lease: https://martinfowler.com/articles/patterns-of-distributed-systems/lease.html
181189
.. _LCG: https://en.wikipedia.org/wiki/Linear_congruential_generator
182190

183191
Clock Rollback
@@ -215,7 +223,7 @@ above was that IDs lost its "monotonically increasing" property [#]_. Ofc, some
215223
of our and other team's code were dependent on this SonyFlake's feature. Duh.
216224

217225
Adding even more workarounds like pre-generate IDs, sort them and ingest was
218-
a compelling idea, but I did not feel right. Hence, this library was born.
226+
a compelling idea, but it did not feel right. Hence, this library was born.
219227

220228
.. [#] E.g. if you cycle through generators with Machine IDs 0xCAFE and 0x1337
221229
You may get the following IDs: ``0x0874b2a7a0cafe00``,

0 commit comments

Comments
 (0)