Tagged articles
56 articles
Page 1 of 1
Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Apr 26, 2026 · Backend Development

Why Misusing JPA findById Hurts Performance and Causes Critical Pitfalls

The article dissects how the default JpaRepository findById method can trigger unnecessary SELECT queries, create foreign‑key violations under concurrency, and degrade performance, then demonstrates three concrete workarounds—including getReferenceById, manual entity construction, and pessimistic read locking—to eliminate these issues.

Spring Bootconcurrencyfindbyid
0 likes · 8 min read
Why Misusing JPA findById Hurts Performance and Causes Critical Pitfalls
Ray's Galactic Tech
Ray's Galactic Tech
Oct 20, 2025 · Backend Development

Pessimistic, Optimistic & Distributed Locks: Core Concepts, Scenarios & Tips

This article explains the fundamental ideas behind pessimistic, optimistic, and distributed locking, compares their strengths and weaknesses, outlines typical application scenarios such as inventory deduction, banking transfers, and cache protection, and provides concrete implementation examples using SQL row locks, version fields, CAS, Redis WATCH, and Lua scripts.

concurrencylockingoptimistic lock
0 likes · 8 min read
Pessimistic, Optimistic & Distributed Locks: Core Concepts, Scenarios & Tips
Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Sep 23, 2025 · Backend Development

Spring Boot 3 Concurrency: Locks, Optimistic & Pessimistic Updates

This article explains common problems of concurrent database updates in Spring Boot 3 and demonstrates five practical solutions—including database locks, optimistic and pessimistic locking, transaction isolation levels, and application‑level locks—accompanied by complete code examples and test results.

Spring Bootconcurrencyoptimistic lock
0 likes · 10 min read
Spring Boot 3 Concurrency: Locks, Optimistic & Pessimistic Updates
Lobster Programming
Lobster Programming
May 30, 2025 · Backend Development

How to Ensure API Idempotency with Locks: 5 Proven Strategies

This article explores five practical lock-based approaches—including database primary keys, pessimistic and optimistic locks, state machines, and distributed locks—to achieve reliable API idempotency in distributed systems, highlighting implementation details, trade‑offs, and code examples.

API idempotencydatabase lockdistributed-lock
0 likes · 7 min read
How to Ensure API Idempotency with Locks: 5 Proven Strategies
Java Backend Technology
Java Backend Technology
May 7, 2025 · Backend Development

When Can Flawed Code Stay Unchanged? A Deep Dive into Concurrency and Locking

The article examines a seemingly harmless Java update snippet that hides a concurrency race condition, discusses why a team might decide not to change it in low‑frequency scenarios, and then presents safer alternatives such as selective updates, optimistic and pessimistic locks, and strict guidelines for financial‑critical code.

Code reviewoptimistic lockpessimistic-lock
0 likes · 11 min read
When Can Flawed Code Stay Unchanged? A Deep Dive into Concurrency and Locking
Su San Talks Tech
Su San Talks Tech
Oct 5, 2024 · Backend Development

Mastering Idempotency: Design Patterns and Code Solutions for Reliable APIs

Idempotency ensures that repeated API calls produce the same result without side effects, and this guide explains its principles, common scenarios like payments and messaging, root causes of idempotency failures, and multiple implementation strategies—including unique constraints, optimistic and pessimistic locks, distributed locks, token mechanisms, state machines, and deduplication tables—with practical code examples.

BackendDistributed SystemsIdempotency
0 likes · 14 min read
Mastering Idempotency: Design Patterns and Code Solutions for Reliable APIs
Su San Talks Tech
Su San Talks Tech
Aug 11, 2024 · Backend Development

Mastering Idempotency: Design Patterns and Code Examples for Reliable APIs

This article explains the concept of idempotency, outlines scenarios where it is essential, analyzes common causes of idempotency issues, and presents multiple practical solutions—including unique constraints, optimistic and pessimistic locks, distributed locks, token mechanisms, state machines, deduplication tables, and global request IDs—accompanied by concrete code examples.

Distributed SystemsIdempotencyToken
0 likes · 14 min read
Mastering Idempotency: Design Patterns and Code Examples for Reliable APIs
Java Tech Enthusiast
Java Tech Enthusiast
Apr 6, 2024 · Backend Development

Inventory Deduction and Concurrency Control in Backend Systems

The article outlines the three‑step inventory deduction workflow—select, verify, update—and explains how concurrent requests can cause overselling, then compares mitigation strategies such as pessimistic SELECT FOR UPDATE locks, optimistic CAS version retries, atomic decrement SQL statements, and Redis transactions, highlighting their trade‑offs in consistency and throughput.

concurrencyinventoryoptimistic lock
0 likes · 5 min read
Inventory Deduction and Concurrency Control in Backend Systems
MaGe Linux Operations
MaGe Linux Operations
Feb 13, 2024 · Fundamentals

Understanding Optimistic vs Pessimistic Locks: When and How to Use Them

This article explains the purpose of locks in concurrent environments, compares optimistic (CAS) and pessimistic locking mechanisms, outlines their advantages, disadvantages, suitable scenarios, and provides PHP/PDO code examples demonstrating implementation and performance testing under high concurrency.

Concurrency ControlPHPmysql
0 likes · 11 min read
Understanding Optimistic vs Pessimistic Locks: When and How to Use Them
政采云技术
政采云技术
Mar 23, 2023 · Backend Development

Distributed Locks: Concepts, Characteristics, and Common Implementation Strategies

This article explains the need for distributed locks in multi‑node systems, describes their core characteristics, and compares popular implementation approaches such as database‑based optimistic and pessimistic locks, Redis atomic locks, and ZooKeeper sequential node locks, highlighting their principles and trade‑offs.

optimistic lockpessimistic-lockredis
0 likes · 8 min read
Distributed Locks: Concepts, Characteristics, and Common Implementation Strategies
Selected Java Interview Questions
Selected Java Interview Questions
Feb 23, 2023 · Backend Development

Understanding Lock Strategies: Optimistic, Pessimistic, Read‑Write, Heavy/Light, Fairness and Reentrancy

This article explains various lock strategies—including optimistic and pessimistic locks, read‑write locks, heavyweight vs. lightweight locks, spin locks, fair vs. unfair locks, and reentrant locks—detailing their definitions, use‑cases, underlying mechanisms, and illustrative examples for concurrent programming in Java and other languages.

javalockingoptimistic lock
0 likes · 10 min read
Understanding Lock Strategies: Optimistic, Pessimistic, Read‑Write, Heavy/Light, Fairness and Reentrancy
ITPUB
ITPUB
Feb 17, 2023 · Databases

Master MySQL Locking: From Row Locks to Deadlocks and How to Prevent Them

This article explains why MySQL needs locking, details every InnoDB lock type—including shared, exclusive, intention, record, gap, next‑key, insert‑intention and auto‑increment locks—shows how they interact, and provides practical guidance for avoiding deadlocks and safely updating rows.

InnoDBIsolation Leveldeadlock
0 likes · 22 min read
Master MySQL Locking: From Row Locks to Deadlocks and How to Prevent Them
IT Services Circle
IT Services Circle
Jun 25, 2022 · Databases

Understanding Optimistic and Pessimistic Locks in MySQL

Optimistic and pessimistic locks are conceptual concurrency control strategies used across databases and caching systems; the article explains their principles, MySQL implementations with SELECT ... FOR UPDATE and version checks, compares their trade‑offs, and advises preferring optimistic locking in high‑concurrency scenarios.

Concurrency Controlmysqloptimistic lock
0 likes · 6 min read
Understanding Optimistic and Pessimistic Locks in MySQL
Top Architect
Top Architect
Feb 26, 2022 · Backend Development

Design and Analysis of a Flash‑Sale System: Architecture, Request Flow, and Lock Strategies

This article analyzes the business scenario of flash‑sale (秒杀) systems, outlines their technical characteristics, dissects the request chain, compares optimistic and pessimistic locking mechanisms with code examples, and presents a comparative table of concurrency‑control outcomes.

Backend ArchitectureConcurrency Controlflash sale
0 likes · 8 min read
Design and Analysis of a Flash‑Sale System: Architecture, Request Flow, and Lock Strategies
IT Architects Alliance
IT Architects Alliance
Feb 24, 2022 · Backend Development

Technical Analysis of Flash‑Sale (秒杀) Systems: Scenarios, Architecture, and Lock Strategies

This article examines flash‑sale business scenarios, outlines their high‑concurrency characteristics, dissects the request‑flow architecture from client to database, and compares optimistic, retry‑optimistic, and pessimistic locking techniques with practical examples and performance considerations.

flash salehigh concurrencyoptimistic lock
0 likes · 8 min read
Technical Analysis of Flash‑Sale (秒杀) Systems: Scenarios, Architecture, and Lock Strategies
Architect
Architect
Feb 24, 2022 · Backend Development

Design and Analysis of Flash‑Sale (秒杀) Systems: Scenarios, Technical Characteristics, Request Chain, and Lock Strategies

This article examines flash‑sale systems by outlining typical business scenarios, analyzing read‑heavy and high‑concurrency technical traits, detailing the end‑to‑end request flow, and comparing optimistic, retry‑optimistic, and pessimistic locking mechanisms with practical SQL examples and performance tables.

Backend Architecturedatabase lockingflash sale
0 likes · 9 min read
Design and Analysis of Flash‑Sale (秒杀) Systems: Scenarios, Technical Characteristics, Request Chain, and Lock Strategies
Java Tech Enthusiast
Java Tech Enthusiast
Nov 18, 2021 · Fundamentals

Pessimistic and Optimistic Locks in Java: Theory and Code Examples

The article compares Java's pessimistic locking mechanisms such as synchronized blocks and ReentrantLock with optimistic approaches like version checks, CAS‑based AtomicInteger and custom spin locks, illustrating each method through counter examples and discussing their performance trade‑offs and limitations.

CASLocksconcurrency
0 likes · 11 min read
Pessimistic and Optimistic Locks in Java: Theory and Code Examples
Senior Brother's Insights
Senior Brother's Insights
Nov 17, 2021 · Databases

How I Fixed Persistent Account Balance Mismatches with Pessimistic Locks and Hibernate

After repeatedly encountering account balance discrepancies in a financial system, I traced the issue to improper use of pessimistic locks and Hibernate caching, then resolved it by correcting lock placement, optimizing SQL queries, and switching to native SQL, sharing the detailed debugging steps and lessons learned.

HibernateSQL Optimizationconcurrency
0 likes · 13 min read
How I Fixed Persistent Account Balance Mismatches with Pessimistic Locks and Hibernate
YunZhu Net Technology Team
YunZhu Net Technology Team
Oct 15, 2021 · Backend Development

Idempotency in Software Systems: Definitions, Real‑World Scenarios, and Implementation Strategies

The article explains the concept of idempotency, illustrates everyday examples of its importance, defines it mathematically and in software, and presents a comprehensive set of practical solutions—including database constraints, frontend controls, locking mechanisms, token‑based forms, message queues, and RPC safeguards—to achieve reliable idempotent behavior in distributed backend systems.

Idempotencyoptimistic lockpessimistic-lock
0 likes · 11 min read
Idempotency in Software Systems: Definitions, Real‑World Scenarios, and Implementation Strategies
Su San Talks Tech
Su San Talks Tech
Jul 27, 2021 · Backend Development

Understanding Java Locks: Optimistic vs Pessimistic, Reentrant, Read‑Write, and More

This article explains the various Java lock mechanisms—including optimistic and pessimistic locks, exclusive and shared locks, reentrant, read‑write, fair/unfair, spin, segment locks, and lock‑escalation techniques—detailing their principles, Java implementations, usage scenarios, and optimization strategies.

Reentrant Lockconcurrencyoptimistic lock
0 likes · 13 min read
Understanding Java Locks: Optimistic vs Pessimistic, Reentrant, Read‑Write, and More
Laravel Tech Community
Laravel Tech Community
Jul 8, 2021 · Databases

Understanding Optimistic and Pessimistic Locks in MySQL/InnoDB

This article explains the concepts, mechanisms, and practical code examples of optimistic and pessimistic locking in MySQL/InnoDB, including version‑based optimistic locks, shared (read) locks, exclusive (write) locks, and how to apply them with Laravel's query builder.

Database ConcurrencyLaravellocking
0 likes · 6 min read
Understanding Optimistic and Pessimistic Locks in MySQL/InnoDB
Selected Java Interview Questions
Selected Java Interview Questions
May 29, 2021 · Databases

Understanding Database Locks: Shared, Exclusive, Mutex, Pessimistic, Optimistic, Row, Table, and Page Locks, and Common Concurrency Issues

This article explains the concepts, usage scenarios, and differences of various database locks—including shared (S) lock, exclusive (X) lock, mutex, pessimistic and optimistic locks—as well as row‑level, table‑level, and page‑level locks, and it discusses common concurrency problems such as lost updates, non‑repeatable reads, dirty reads, and deadlocks.

Concurrency ControlDatabase Locksmysql
0 likes · 8 min read
Understanding Database Locks: Shared, Exclusive, Mutex, Pessimistic, Optimistic, Row, Table, and Page Locks, and Common Concurrency Issues
Full-Stack Internet Architecture
Full-Stack Internet Architecture
May 20, 2021 · Backend Development

Designing a High‑Concurrency Flash‑Sale (秒杀) System: From Naïve Implementation to Optimized Solutions

This article walks through the design of a flash‑sale system, starting with a simple SpringBoot‑MyBatis implementation, then addressing overselling with pessimistic and optimistic locks, applying rate‑limiting algorithms, time‑window controls, interface hiding, frequency limits, and a suite of production‑grade optimizations such as CDN, Nginx load balancing, Redis caching, message queues, and short‑URL handling.

SpringBootflash saleoptimistic lock
0 likes · 14 min read
Designing a High‑Concurrency Flash‑Sale (秒杀) System: From Naïve Implementation to Optimized Solutions
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Apr 18, 2021 · Backend Development

Idempotency: Definition, Scenarios, and Implementation Strategies

The article explains the concept of idempotency, distinguishes it from duplicate submissions, outlines typical use cases such as network retries and form resubmissions, and presents various backend solutions—including unique indexes, deduplication tables, pessimistic and optimistic locks, distributed locks, and token‑based approaches—complete with SQL examples.

IdempotencyTokenoptimistic lock
0 likes · 11 min read
Idempotency: Definition, Scenarios, and Implementation Strategies
Programmer DD
Programmer DD
Dec 29, 2020 · Backend Development

Mastering Locks: Optimistic, Pessimistic, and Distributed Strategies for High-Concurrency Systems

This article explains the different lock types—pessimistic, optimistic, and distributed—covers their use cases, compares their advantages and drawbacks, and provides concrete code examples and four practical solutions for handling high‑concurrency deduction scenarios such as inventory or balance reduction.

distributed-lockjavaoptimistic lock
0 likes · 13 min read
Mastering Locks: Optimistic, Pessimistic, and Distributed Strategies for High-Concurrency Systems
Senior Brother's Insights
Senior Brother's Insights
Nov 30, 2020 · Backend Development

Ensuring Idempotency in Distributed Systems: Strategies and Code Examples

The article explains why idempotent operations are essential in backend and financial systems, describes the mathematical concept, and presents practical techniques such as unique indexes, token validation, pessimistic and optimistic locking, distributed locks, state‑machine design, and API patterns with concrete SQL examples.

Idempotencydatabaseoptimistic lock
0 likes · 8 min read
Ensuring Idempotency in Distributed Systems: Strategies and Code Examples
Laravel Tech Community
Laravel Tech Community
May 21, 2020 · Databases

When to Use Optimistic vs. Pessimistic Locks in MySQL (and Redis)

This article explains the concepts, advantages, and drawbacks of MySQL pessimistic and optimistic locks, shows how to implement each with SQL and PHP code, compares their suitability for different traffic patterns, and demonstrates a Redis‑based optimistic lock for high‑concurrency flash‑sale scenarios.

PHPconcurrencymysql
0 likes · 10 min read
When to Use Optimistic vs. Pessimistic Locks in MySQL (and Redis)
macrozheng
macrozheng
Mar 25, 2020 · Backend Development

Mastering Token Bucket Rate Limiting and Lock Strategies in Flash Sale Systems

This article explains how to implement token‑bucket rate limiting with Guava's RateLimiter, compare it to leaky‑bucket algorithms, and combine it with optimistic and pessimistic locking techniques to prevent overselling in high‑concurrency flash‑sale applications.

Token Bucketjavaoptimistic lock
0 likes · 15 min read
Mastering Token Bucket Rate Limiting and Lock Strategies in Flash Sale Systems
Programmer DD
Programmer DD
Jul 9, 2019 · Backend Development

Master Transaction Locks in Spring Data JPA: Pessimistic vs Optimistic

This tutorial explains how to enable and configure transaction locks—including pessimistic and optimistic modes—in Spring Data JPA repositories, demonstrates the use of @Lock and @QueryHints annotations, and shows how to set lock timeouts to ensure data integrity under high concurrency.

LockModeTypejavaoptimistic lock
0 likes · 6 min read
Master Transaction Locks in Spring Data JPA: Pessimistic vs Optimistic
dbaplus Community
dbaplus Community
Jun 16, 2019 · Fundamentals

Understanding Thread Safety: From ThreadLocal to Locks and CAS

This article explains why thread safety concerns memory rather than threads, compares stack‑local and heap‑shared data, introduces ThreadLocal for per‑thread isolation, and covers mutual‑exclusion locks, optimistic CAS, and their appropriate use cases in concurrent programming.

CASJava concurrencyLocks
0 likes · 15 min read
Understanding Thread Safety: From ThreadLocal to Locks and CAS
ITPUB
ITPUB
Apr 25, 2019 · Databases

Pessimistic vs Optimistic Locks: Choosing the Right Concurrency Control for High‑Traffic Databases

This article explains the concepts of concurrency control, detailing pessimistic and optimistic locking mechanisms, their implementation in MySQL, practical SQL examples, advantages, drawbacks such as deadlocks and ABA problems, and guidance on selecting the appropriate lock strategy for high‑concurrency applications.

CASConcurrency ControlVersioning
0 likes · 11 min read
Pessimistic vs Optimistic Locks: Choosing the Right Concurrency Control for High‑Traffic Databases
Architects' Tech Alliance
Architects' Tech Alliance
Apr 3, 2019 · Databases

Choosing Between Optimistic and Pessimistic Locks in Production Systems

The article explains the concepts, advantages, and drawbacks of optimistic and pessimistic locking, provides real‑world examples such as lost updates and inconsistent reads, and offers practical guidelines and implementation techniques for selecting the appropriate concurrency control strategy in database‑driven applications.

Concurrency ControlIsolationVersion Control
0 likes · 10 min read
Choosing Between Optimistic and Pessimistic Locks in Production Systems
ITFLY8 Architecture Home
ITFLY8 Architecture Home
Mar 29, 2019 · Backend Development

How MVCC Beats Pessimistic Locks for Distributed Key‑Value Stores

This article examines a distributed system concurrency problem, compares lock‑based transactions with multiversion concurrency control (MVCC), and explains why MVCC often outperforms pessimistic locking in scenarios demanding high read responsiveness and low contention.

Concurrency ControlDistributed SystemsMVCC
0 likes · 10 min read
How MVCC Beats Pessimistic Locks for Distributed Key‑Value Stores
Java High-Performance Architecture
Java High-Performance Architecture
Jan 22, 2019 · Backend Development

How to Prevent Inventory Over‑Selling in High‑Concurrency Systems

Learn why inventory over‑selling occurs under high concurrency, and explore three practical solutions—pessimistic locking, optimistic locking with version control, and Redis‑Lua scripting—detailing their implementation steps, advantages, and drawbacks to help you choose the best approach for reliable stock management.

Luainventorypessimistic-lock
0 likes · 7 min read
How to Prevent Inventory Over‑Selling in High‑Concurrency Systems
Architect's Tech Stack
Architect's Tech Stack
Dec 22, 2018 · Backend Development

Understanding Idempotency: Concepts, Examples, and Implementation Techniques

This article explains the mathematical and programming concept of idempotency, provides real‑world examples such as duplicate form submissions and payment requests, and details practical techniques—including query/select operations, unique indexes, token mechanisms, pessimistic and optimistic locks, distributed locks, and API design—to ensure idempotent behavior in backend systems.

Distributed SystemsIdempotencydatabase
0 likes · 9 min read
Understanding Idempotency: Concepts, Examples, and Implementation Techniques
Java Captain
Java Captain
Sep 25, 2018 · Fundamentals

Optimistic vs Pessimistic Locks and CAS Implementation in Java

The article explains the concepts of pessimistic and optimistic locking, details how CAS (Compare‑And‑Swap) implements optimistic locks in Java, discusses their advantages, drawbacks such as the ABA problem and high spin costs, and compares CAS usage with synchronized blocks in concurrent programming.

CASJava concurrencySynchronization
0 likes · 14 min read
Optimistic vs Pessimistic Locks and CAS Implementation in Java
Architects' Tech Alliance
Architects' Tech Alliance
Sep 11, 2018 · Databases

Pessimistic vs Optimistic Locking: A Story-Based Explanation

This article uses a humorous story of two threads battling over inventory updates to illustrate the principles, advantages, and drawbacks of pessimistic and optimistic locking in distributed systems, helping readers understand when to apply each concurrency control method.

Concurrency ControlDistributed Systemsdatabase
0 likes · 8 min read
Pessimistic vs Optimistic Locking: A Story-Based Explanation
Architecture Digest
Architecture Digest
Jan 25, 2018 · Backend Development

Handling Concurrency and Preventing Duplicate Ticket Booking in Train Ticket Systems

The article examines how a train ticket ordering system can encounter duplicate bookings when multiple users concurrently request the same seat and evaluates four different locking strategies—including flag fields, pessimistic locks, synchronized blocks, and a hybrid optimistic‑pessimistic approach—to ensure data consistency and avoid over‑booking.

Backendlockingoptimistic-lock
0 likes · 5 min read
Handling Concurrency and Preventing Duplicate Ticket Booking in Train Ticket Systems
ITPUB
ITPUB
Oct 26, 2016 · Databases

Mastering Oracle Locks: Pessimistic, Optimistic, and Deadlock with Real‑World SQL demos

This guide explains Oracle's lock mechanisms—including shared, exclusive, row‑level, pessimistic, and optimistic locks—through step‑by‑step SQL sessions that illustrate update‑lost problems, lock contention, and deadlock detection, helping developers choose the right strategy for concurrency control.

Oracleoptimistic lockpessimistic-lock
0 likes · 10 min read
Mastering Oracle Locks: Pessimistic, Optimistic, and Deadlock with Real‑World SQL demos
Java Backend Technology
Java Backend Technology
Oct 25, 2016 · Databases

Why Locks Matter: Pessimistic vs Optimistic Concurrency Control Explained

This article explains why locks are needed in multi‑user environments, describes common conflict types such as lost updates and dirty reads, compares pessimistic and optimistic locking mechanisms, shows practical implementations with version numbers and SQL Server locks, and presents a classic financial‑system case study.

optimistic lockpessimistic-locktransaction
0 likes · 8 min read
Why Locks Matter: Pessimistic vs Optimistic Concurrency Control Explained