Reputation: 561
Please let me know the best practices of providing application concurrency in software project. I would like to use Hibernate for ORM. Spring to manage the transactions. Database as MySQL.
My concurrency requirement is to let as much as users to connect to the database and
make CRUD operations and use the services. But I do not like to have stale data.
@Transactional(isolation=Isolation.READ_COMMITTED)
. How to take that decision.?I have come up with below items would like to know your feedback and the way to address?
a. How to handle data concurrency issues in DB. Use Version Tag and Timestamp.
b. How to handle application concurrency. Provide optimistic locking. Not using synchronizations but create objects for each requests (Scope prototype).
c. What are the best practices. cache objects whenever its possible.
Upvotes: 0
Views: 310
Reputation: 691665
@Version
fields in your entities if needed.Regarding your point c (cache objects whenever possible), I would say that this is exactly what you shouldn't do. Caching makes your app stateful, difficult to cluster, much more complex, and you'll have to deal with the staleness of the cache. Don't cache anything until
Databases are fast, and already cache data in memory for you.
Upvotes: 3