WLock: High‑Reliability, High‑Throughput Distributed Lock Service Based on WPaxos
WLock is an open‑source distributed lock service built on the WPaxos consensus algorithm and RocksDB storage, offering multiple lock types, flexible acquisition modes, high concurrency optimizations, and strong reliability and throughput for coordinating shared resources in distributed systems.
WLock is an open‑source distributed lock service built on the WPaxos consensus component, offering high reliability and high throughput for coordinating access to shared resources in distributed environments.
Core features include multiple lock types (re‑entrant, fair, priority, read‑write, process, thread), flexible lock operations (blocking/non‑blocking, sync/async watch, TTL, lease renewal), multi‑tenant isolation, and an easy‑to‑use API.
Reliable storage design uses RocksDB for persisting lock state and WPaxos for multi‑replica synchronization and automatic master‑slave failover. Locks are hashed to a fixed Paxos group; the master proposes state changes to slaves, ensuring strong consistency.
Lock operation implementation demonstrates re‑entrant lock handling via an AcquireCount counter, blocking vs non‑blocking acquisition, watch‑event heartbeats, and automatic or manual lease renewal to avoid deadlocks.
High‑concurrency optimizations employ multiple Paxos groups with evenly distributed masters, multi‑threaded request handling, and batch Propose calls to reduce network and context‑switch overhead.
The performance evaluation on a 3‑node cluster (20 × Xeon Silver 4114, 192 GB RAM, SSD, 10 GbE) shows WLock achieving superior QPS and lower latency compared to Redis, Zookeeper and Etcd, while maintaining strong reliability.
Future plans include multi‑language SDKs (Go, PHP, Node), a web management console, monitoring modules, and support for distributed semaphore mechanisms.
References: WPaxos source code, Martin Kleppmann’s “How to do distributed locking”, and related articles.
58 Tech
Official tech channel of 58, a platform for tech innovation, sharing, and communication.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.