Friday, October 16, 2009

DB Usage Tips from eBay

Tip #1: Don't use transactions
instead, each record has a status and a version #
For inserts:
  1. add parent
  2. add children
  3. set children status to active
  4. set parent status to active
For updates:
  1. insert parent w/ higher version #
  2. insert children w/ higher version #
  3. set children status to active
  4. set parent to active
If a failure occurs, clean up orphans.

Tip #2: no joins allowed
Use lots of tables instead (easier to partition)
Joins can easily overload a database.
Offload logic to easily load balanced app servers
db is just data in and out

Tip #3: Limit # of returned rows using where clause
>20,000 rows returned is threshold
100k allowed in some cases
Even if you could get 100k results, probably can't process them.

No comments:

Labels

Blog Archive

Contributors