Back to Developer Roadmap

Optimistic Vs Pessimistic

src/data/question-groups/backend/content/optimistic-vs-pessimistic.md

4.0532 B
Original Source

Optimistic locking is a strategy that:

  • Assumes conflicts are rare and don’t happen that often.
  • Allows for concurrent data access.
  • Checks if there are conflicts before committing.
  • It’s best used in high-read, low-write scenarios.

Pessimistic locking, on the other hand, is a strategy that:

  • Assumes conflicts to be very common.
  • Locks data and prevents concurrent access.
  • Holds these locks for the duration of a transaction.
  • It’s best suited for high-write scenarios or when data integrity is critical.