This article explains ZooKeeper’s architecture, key concepts such as roles, sessions, ZNodes, versioning, ACLs, and watchers, and demonstrates how it powers essential big‑data components like Hadoop’s ResourceManager and HBase’s master election, naming service, and distributed locking.
Distributed locks ensure that, across hundreds of servers handling millions of concurrent red‑packet requests, only one instance updates the shared total at a time, preventing inconsistencies and deadlocks, with implementations ranging from Java synchronized blocks to Redis SETNX and Zookeeper Znode mechanisms.
This article chronicles the design, evolution, and performance evaluation of Bond, a distributed‑lock SDK used internally at Youzan, covering its multi‑phase roadmap, storage choices, timeout‑retry strategies, lock‑TTL recommendations, and practical pitfalls for reliable operations.
This article walks through a complete performance‑testing setup for a VIP purchase callback API, detailing the request flow, distributed‑lock handling with Redis, parameter generation using AtomicInteger, Java implementation, and pitfalls to ensure accurate, high‑concurrency testing.
This article explains how to implement a Redis-based distributed lock using Jedis in Java, covering lock creation with SETNX, lock expiration, safe lock release via Lua scripts, and demonstrates the approach by simulating a 100,000-user concurrent order‑grabbing scenario.
This comprehensive guide explains the benefits of microservices and walks through core building blocks such as RPC, service discovery, configuration management, task scheduling, distributed locking, unified monitoring, caching strategies, message queues, distributed transactions, CAP theory, seckill handling, Docker isolation, and modern CI/CD deployment pipelines.
The article explains why idempotent operations are essential in high‑traffic systems, defines idempotency, and presents a comprehensive set of techniques—including unique indexes, token validation, pessimistic and optimistic locking, distributed locks, select‑plus‑insert patterns, state‑machine design, and API safeguards—to guarantee consistent outcomes even under repeated requests.
This article explains Zookeeper's core features—such as its tree‑like directory, persistent and ephemeral nodes, sequential ordering, and watcher mechanism—and demonstrates how these capabilities enable distributed locks and service registration/discovery within microservice architectures.
Service DiscoveryZooKeeperdistributed coordination
This article explains the Redis concurrent key competition problem, illustrates typical scenarios where multiple clients modify the same key, and presents four practical solutions—optimistic locking with WATCH/EXEC, distributed locks, timestamp ordering, and message‑queue serialization—to ensure data correctness under high concurrency.
This article explains the definition of distributed locks, the challenges of mutual exclusion in distributed environments, and compares four implementation approaches—plain Redis, ZooKeeper, and Redisson—detailing their mechanisms, advantages, drawbacks, and practical code examples.
This article shares a practical experience of implementing a Redis‑based distributed lock, explains the lock acquisition and release processes, discusses common pitfalls such as expiration handling and concurrency bugs, and provides Q&A on design choices, high‑availability, and future improvements.
This article explores the design and implementation of a Redis‑based distributed lock used since 2013, analyzes lock acquisition and release mechanisms, discusses common pitfalls such as expiration handling and race conditions, and presents possible improvements like Lua scripts and Redisson.
This article explores Redis beyond its traditional caching role, covering distributed locks, message queues, bitmaps, Bloom filters, geolocation, and rate limiting, while highlighting typical implementation patterns, code examples, and the inherent limitations of each scenario.
This article explains a Java backend architecture with front‑end/back‑end separation, deployment diagrams, the concepts of thread, process and distributed locks, implementations using database optimistic locking, Redis and Zookeeper, session handling in distributed systems, and various related code examples and best‑practice notes.
This article details how a new‑car e‑commerce CRM system was optimized for high availability by introducing ZooKeeper‑based distributed locks, mitigating herd effects, segmenting locks per merchant, and redesigning Redis caching with sorted sets to efficiently rank consultants by daily call volume, resulting in significant performance gains under high concurrency.
This article explains Redis' core data types—strings, lists, sets, hashes, sorted sets, and more—detailing their characteristics, common commands, practical use‑cases such as caching, counters, distributed locks, and ranking, and provides best‑practice tips for key design and performance.
When using ZooKeeper‑based distributed locks, applications must detect CONNECTIONLOSS and SESSIONEXPIRED events, verify the master znode to confirm leadership, relinquish duties on session expiry, and design idempotent tasks to avoid split‑brain or duplicate execution caused by network partitions or quorum delays.
This article introduces distributed locks, explains why they are needed in distributed environments, outlines their characteristics and requirements, and compares three implementation approaches—plain Redis, ZooKeeper, and Redisson—detailing their advantages, drawbacks, and code examples.
This article provides a comprehensive introduction to ZooKeeper, covering its definition, ZNode hierarchy, listener mechanisms, and practical applications such as unified configuration management, naming services, distributed locks, and cluster state monitoring, illustrating how these features enable robust coordination in distributed systems.
This article provides a comprehensive overview of Redis, covering its definition, common use cases, core functionalities, differences from Memcached, single‑threaded design, cache‑penetration mitigation, supported data types, Java clients, consistency strategies, persistence methods, distributed lock implementation, memory optimization, eviction policies, and typical performance issues.
This article explains Zookeeper as an open‑source distributed coordination service, detailing its core functions such as cluster management, leader election, distributed locks, and naming service, along with its three deployment modes, state‑synchronization via the ZAB protocol, and its watcher‑based notification mechanism.
This article explains why duplicate requests occur, defines idempotency, and presents common backend strategies—such as unique indexes, optimistic locks, anti‑repeat tokens, anti‑repeat tables, and distributed locks—illustrated with an order‑processing workflow.
This article explains why traditional in‑process locks fail under massive concurrency, how distributed locks using Redis or Zookeeper ensure atomic updates across many servers, and details practical implementations, pitfalls like deadlocks, and strategies such as key expiration and ephemeral sequential nodes.
Distributed locks provide mutual exclusion across multiple nodes in scalable, reliable systems, and can be implemented via simple Redis SETNX/EX patterns, ZooKeeper’s EPHEMERAL_SEQUENTIAL znodes with watches, or Redisson’s advanced Java‑centric primitives, each offering distinct trade‑offs in simplicity, consistency, and feature richness.
This article analyzes data‑inconsistency problems caused by concurrent multithreaded updates in a CMDB system and presents a step‑by‑step exploration of synchronization solutions, ultimately implementing a robust Redis‑backed distributed lock in Python to guarantee atomic reads and writes while handling edge cases such as crashes and lock expiration.
This article explains how Zookeeper can be used to build distributed locks, detailing the implementation of exclusive locks and two variants of read‑write locks, complete with step‑by‑step processes, node structures, watcher mechanisms, and practical considerations for backend systems.
This article explains how to implement ordinary Redis distributed locks and the advanced Redlock algorithm using Redisson across single‑node, sentinel, and cluster architectures, provides complete Java code examples, and addresses common questions about expiration, high availability, and comparisons with Zookeeper.
This article reviews the evolution of Redis‑based distributed lock implementations—from the simple V1.0 pattern to the more robust V3.1 and Redlock algorithm—highlighting their mechanisms, common pitfalls, and guidance on selecting the most suitable lock for a given scenario.
This article explains the classic Redis distributed lock using SETNX and Lua, highlights its pitfalls, introduces the advanced Redlock algorithm with step‑by‑step acquisition and release procedures, and provides concrete Java Redisson code examples, illustrating how to implement reliable distributed locks across multiple Redis nodes.
This article introduces the "Big Data Mastery" series and outlines practical solutions for three frequent distributed system challenges—distributed locks, distributed transactions, and distributed ID generation—while highlighting open‑source tools and key design requirements.
This tutorial explains how to integrate the ShedLock library with Spring, covering Maven dependencies, JDBC table setup, required annotations, and example code for creating synchronized scheduled jobs that run on only one instance at a time.
This article explains the business background of a flash‑sale (seckill) scenario, analyzes naive locking approaches, introduces Redis‑based distributed locks, and provides a complete Java demo with custom annotations, dynamic proxies, and a multithreaded test to ensure correct inventory decrement under high concurrency.
This article details the requirements analysis, design choices, architecture, code implementation, monitoring, and special considerations of ZZLock, a high‑performance distributed lock solution built on Etcd that ensures atomicity, consistency, and fault‑tolerance for backend services.
Learn how to implement Redis distributed locks in both single‑node and cluster environments, covering lock acquisition and release commands, key pitfalls like master‑slave failover, and the advanced Redlock algorithm with step‑by‑step guidance, Lua scripts, and a PHP lock class example.
This article examines the design and implementation of distributed locks using databases, Redis, and Zookeeper, outlining their core characteristics, practical code patterns, performance trade‑offs, fault‑tolerance mechanisms, and guidance on selecting the right solution for specific workloads.
This article compares Google’s Chubby lock service with Apache Zookeeper, explains their design philosophies, system architectures, the Zab protocol versus Paxos, and demonstrates how Zookeeper can be used for naming services, publish‑subscribe, distributed transactions, and distributed locks with concrete Java code examples.
This article presents a comprehensive design of a high‑availability red‑envelope system, covering its data model, generation, distribution, verification, query optimization, and product tagging strategies, while detailing the use of Redis, distributed locks, MQ, and caching to meet complex business scenarios.
This article explains the principles, requirements, and implementation details of distributed lock services, comparing Redis and ZooKeeper approaches, and introduces SharkLock's design built on SharkStore with Raft-based replication, covering lock acquisition, release, reliability, scaling, and failover mechanisms.
This article explains the principles of distributed locks, compares Redis‑based and ZooKeeper‑based implementations, discusses their limitations, and introduces the SharkLock system built on SharkStore with Raft‑based replication, detailing its reliability, dead‑lock prevention, and safety mechanisms.
This article explains why distributed locks are essential for maintaining data consistency in distributed systems, outlines their key requirements, and compares three common implementation approaches—database‑based, Redis‑based, and ZooKeeper‑based—complete with code examples and practical considerations.
This article describes how the Beetle efficiency platform addresses multi‑active deployment challenges by solving session‑sharing, distributed locking, and task‑recovery problems to enable seamless service upgrades and bug fixes without user disruption.
This article analyzes the principles, advantages, and drawbacks of distributed locking with Redis and Zookeeper, comparing single‑node and cluster scenarios, discussing RedLock, EPHEMERAL znodes, and practical failure cases to help engineers choose the right solution.
This article presents a comprehensive design of a flash‑sale (seckill) architecture, covering business characteristics, user scale, layered system components, optimization strategies, full‑link stress testing, and a complete SpringBoot code example with distributed locks, message queues, and database sharding.
This article provides a comprehensive overview of Redis, covering its performance benefits, single‑threaded speed, data types, expiration policies, memory eviction strategies, consistency challenges with databases, and practical techniques for handling cache penetration, snowball effects, and concurrent key conflicts.
This article explains the concept of distributed locks and provides step‑by‑step implementations using Redis's SET command with NX/EX options and Zookeeper's persistent and sequential znodes, including lock acquisition, release, and failure handling.
This article explains the principles of distributed locks, discusses why they are needed in distributed applications, and provides a complete Java implementation using Redis’s NX and EX parameters, including lock acquisition, blocking and non‑blocking modes, unlocking with Lua scripts, configuration, usage examples, and testing strategies.
This article explains how to avoid data races in high‑traffic distributed systems by comparing pessimistic and optimistic concurrency control, demonstrating RDBMS row locks and a Redis‑based distributed lock implementation with Python code examples.
This article explains why distributed locks are needed in Java applications, outlines the essential conditions they must satisfy, and compares three practical implementations—database‑based, Redis‑based, and Zookeeper‑based—providing code snippets and performance considerations for each.
This article explains how to correctly implement a Redis-based distributed lock in Java, covering essential reliability requirements, step‑by‑step code for acquiring and releasing locks, and detailed analyses of common flawed approaches, ensuring atomicity and proper ownership handling.
This article explains ZooKeeper's distributed coordination architecture, the ZAB consensus protocol, server roles, write and read workflows, FastLeaderElection mechanics, configurable election algorithms, and how ZooKeeper can be used to implement reliable distributed locks and leader election.
This article analyzes a real Alibaba internal financial‑system incident where a one‑cent accounting error arose from concurrent database writes after a distributed‑lock timeout, details the root‑cause investigation, and presents two remediation strategies—adjusting timeout settings and strengthening idempotent controls—to prevent similar issues.
A tiny 0.01‑yuan discrepancy in an Alibaba product revealed duplicate settlement records, exposing a distributed‑lock timeout and concurrency issue that led to double commits, and the article walks through the root‑cause analysis, reverse engineering of the process, and two remediation strategies focusing on timeout adjustments and idempotency controls.
This article explains how to build reliable distributed locks with Redis, covering essential commands, common pitfalls, improvements using GETSET, Lua scripting for atomicity, and complete Java code examples that address deadlock and unlock vulnerabilities.
This article provides a comprehensive overview of ZooKeeper, covering its purpose, design goals, architecture, key features, data flow, components, and common application scenarios such as service naming, configuration management, cluster coordination, distributed locks, and queues.
The article describes how JD Daojia's inventory system serves millions of stores by using health‑monitoring platforms, pre‑allocation policies, idempotent order processing, distributed locks, and rollback mechanisms to ensure stability, prevent overselling, and handle high‑concurrency scenarios such as flash‑sales.
This article explains how to replace Redis‑based lock with Curator's InterProcessMutex, detailing its re‑entrant design, node creation, lock acquisition logic, waiting mechanisms, and release process, while highlighting advantages over traditional Thread.sleep approaches in multithreaded resource access.
The article provides a comprehensive overview of TXSQL, Tencent's heavily customized MySQL kernel, detailing its motivations, version choices, performance improvements such as read‑view and redo‑log optimizations, added functionalities like multi‑mode operation and distributed locks, stability testing, financial‑grade features, benchmark results against official MySQL releases, upcoming support for MySQL 5.7, and future development directions.
This article explores the challenges of mutual exclusion and idempotency in distributed environments, explains the underlying principles of locks in multi‑threaded and multi‑process contexts, and presents practical implementations using Zookeeper, Redis, Tair, and the Cerberus and GTIS frameworks to ensure reliable, scalable operations.
To prevent duplicate operations such as repeated inserts, updates, or message sends in high‑traffic applications, this article explains the concept of idempotency and outlines practical techniques—including read‑only APIs, MVCC with optimistic locking, deduplication tables, distributed locks, safe deletes, unique indexes, UUID‑based request tracking, and state‑machine safeguards.
An in‑depth review of the heated debate between Redis creator antirez and distributed‑systems expert Martin Kleppmann over the safety of Redis’s Redlock algorithm, covering single‑node lock pitfalls, failover issues, timing assumptions, fencing tokens, and practical recommendations for when to use Redlock versus simpler locks.
This article reviews the evolution of distributed locking—from simple MySQL table locks to Redis cache locks and the Redlock algorithm—examines expert criticisms of Redlock’s correctness, presents the Redis author’s rebuttal, and ultimately recommends Zookeeper as a more reliable solution for high‑availability distributed locks.
The article examines how distributed systems face mutual‑exclusion and idempotency challenges, explains traditional thread and process synchronization, then details distributed‑lock techniques (e.g., Zookeeper, Redis, Tair, Cerberus) and global‑ID‑based idempotent services, emphasizing the importance of external storage, fault‑tolerance, and proper lock granularity for reliable high‑throughput applications.
Distributed locks prevent concurrent conflicts over shared resources in distributed systems, and this article explains ZooKeeper’s approach using ordered sequential nodes, illustrating the lock acquisition and release process with command-line examples and a complete Java implementation.
This article introduces the Alicom‑Frame library from Alibaba’s Telecom Billing Refactor project, detailing its modular utilities such as flexible DAO with sharding support, method‑level caching, Diamond‑based configuration tools, distributed locks, and various helper classes, illustrating how they simplify backend development.
This article explains how to build reliable distributed locks using Redis, introduces the official RedLock algorithm, discusses safety properties, compares it with simple failover approaches, and provides implementation details, performance considerations, and lock‑extension techniques.
The discussion explores various backend techniques—SQL conditional updates, scheduled tasks, cache flags, database and Redis locks, queues, and token‑based idempotency—to reliably manage e‑commerce inventory and avoid overselling under different traffic loads.