TopDev - High Performance and Scalability Database Design - V2.1
TopDev - High Performance and Scalability Database Design - V2.1
Database Design
Scopes
What will include What will NOT include
https://goo.gl/nF95Nf
○ Scalability ○ Maintenance
Complexity
Business
changing
velocity
Data Intensive - Complexity
Code changes
Data size growth by one of our Application year-
over-year
If we don’t well prepare
> Service Unavailable > Traffic Drop
If we don’t well prepare
Panic!!!
Quite a lots!!!
Approaches
#1 Pick the right tools for your demand
o No One-size-fit-all
o Some pitfalls:
0s 5
24h
min
cacheable
Approaches
#1 Pick the right tools for your demand
Transactional DB
Read locking
Virtual Item
Physical item
Unlimited purchases
Discount 30%
1 item only
1000 purchasing attempts!!!
Approaches
#2. Precise (trust) more important than scaling (ready)
… again, $$$
Approaches
#3. Testing yourself
Benchmark
o Server: sysbench
o Database: mysqlslap
Stay alerted
Daily reports
User Traffic
Rule of thumb: 80/20
o >80% Traffic hit to cache, doesn’t need slow
I/O DB Transaction Processing, require <20%
resource cost
Analytical system
o Different complexity
Other:
Data cache
Query cache
Pre-calculated data
Real-data
A Traffic Spike
Data Cache and Indexed Data
Cache: Indexed Data:
Passive Active
clear()
Target Target
page or page or
Data Changed Worker
Data Data
build()
5
buildCache()
min
Scale Reporting (1)
Simple approach
Scale Reporting (2)
Data-warehouse approach
Example: Analytical Service, BI Tool
Indexing problems
Lock/Deadlock
Investigation:
o Profiling
Powerful tools:
o percona pt-query-digest
Indexing
Key of performance
Fields to be indexed:
○ How to avoid?
Pre-calculation
On-demand calculation vs Pre-calculation
Foreign keys
o Hidden logics
o Hard to monitor
o Some contrainsts
Tools