Re:Ask YC: How do you handle locking in your app?
by fauigerzigerk on Monday October 15, 2007 @11:18AM
(#68063)
I usually use optimistic row level locking for typical structured data in a 3NF data model. If there is so much contention for a particular record that pessimistic or column level locking is necessary there might be a problem with the design of the data model or workflow. There are of course rare situations where pessimistic locking is justified. The canonical one is multi hop flight reservations.
Handling semi structured data (documents of some sort) is way trickier and depends a great deal on the particular data format and patterns of use. Merging is desirable but very hard to achieve in many cases.
One other thing that is worth thinking about is how the locking strategy scales. The most popular idea these days is to seperate read and write operations so all writes go to one DBMS server and the reads are distributed to replicas. That's ugly to integrate after the fact, so if you expect your app to grow fast you should probably design it like that from the start.
Handling semi structured data (documents of some sort) is way trickier and depends a great deal on the particular data format and patterns of use. Merging is desirable but very hard to achieve in many cases.
One other thing that is worth thinking about is how the locking strategy scales. The most popular idea these days is to seperate read and write operations so all writes go to one DBMS server and the reads are distributed to replicas. That's ugly to integrate after the fact, so if you expect your app to grow fast you should probably design it like that from the start.