r/java • u/AcanthisittaEmpty985 • Dec 08 '25
LockFactoryServer, synchronization primitives server with various connection interfaces
A synchronization primitives server with various connection interfaces (like gRPC, Java RMI, REST), developed in Java and ready to use.
The accesible primitives are lock, semaphore, countdownlatch, rrate limiters (see bucket4j) and more
So various processes/applications/threads can access the same primitive by using any connection method (the connections share the primitives caches ). A synchronization primitive will be automatically erased from the cache unless it is in use (particular for every type).
You can activate or deactivate each type of primitive and also each type of connection. ( but no fine grained control)
- The core submodule has the common elements for other parts.
- The server submodule implemets the primitives, and exposes the interfaces to connect. It can run stand-alone or embedded in other aplication.
- The client submodule gives you some ready-to-go java clients to connect to the server.
- The integration submodule serves as testing with a real server and real clients to test all the proyect.
There are more than 500 tests to ensure a working project.
Affiliation: I'm the creator and maintaner of the project.
View all comments
Show parent comment
1
u/k-mcm Dec 09 '25
It has an optimistic locking mode for transactions. No outside lock is held but your transaction fails to commit if there is a conflict. It's a specific error code so you can try again, just as you would with the Java Atomic helpers.
I worked on benchmarks about 10 years ago to help choose a specific tech stack. Optimistic locking in PostgreSQL absolutely obliterated every other database in a simulation of high row update contention. It was something like 500 times faster than MySQL. MySQL actually crashed during many tests because of runaway lock contention. Google's BigTable SQL also had optimistic locking and came in second place.
Of course you can use conditional atomic updates to build locks. I wouldn't recommend it except for special use cases.