Concurrent user updating stock with php

posted by | Leave a comment

Classical locking mechanisms have numerous ways of implementation at the database-level but JPA supports two types of locking mechanisms at the entity-level: optimistic model and pessimistic model.In optimistic locking, it is assumed that the transaction which changes/modifies the entity is engaged in isolation; in other words, it is assumed that this transaction is the only one playing with the entity currently.

Systems for reservations, banking, credit card processing, stock markets, etc.

Obvious, this model of transaction does not acquire any locks until an actual transaction has been made, which usually is obtained at the end of the transaction.

This is only possible when the query is fired to send data to the database and update at flush time.

It is a technique that allows multiple users to access the same data at the same point in time and yet ensure the data remains consistent across all subsequent requests.

This article looks at what concurrency is, the types of concurrency, the techniques involved in implementing each of them, the pros and cons of each of the concurrency handling techniques, the performance issues involved, and when we should use one over the other in our applications.

Leave a Reply

Xxx chatting message