SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
Migrating from PostgreSQL to MySQL Without Downtime
Migrating from PostgreSQL to MySQL Without Downtime
1.
Migrating from
PostgreSQL to MySQL
... without downtime
Matthew Graham
Percona Live NYC 2011
2.
Global marketplace for
buying and selling handmade goods
Total April 2011
• 8 million members • $38.7 million goods sold
• 800k active shops • 2 million items sold
• 1 billion page views / month • 1.8 million new items listed
• 390k new members joined
3.
Global marketplace for
buying and selling handmade goods
Total April 2011
• 8 million members • $38.7 million = $900 / min
• 800k active shops • 2 million items sold
• 1 billion page views / month • 1.8 million new items listed
• 390k new members joined
17.
Generating IDs
Source Target
ID Name ID Name
1 Adam 1 Adam
2 Bill 2 Bill
3 Charlie 3 David
4 David 4 Charlie
Ticket Server: http://bit.ly/dbtickets
22.
Backfill Speed
Application Code ETL
• Easier to Write • Faster Run Time
23.
Backfill Extract
Application Code ETL
• Easier to Write • Faster Run Time
• Less Likely to Get Out • Needs an Extract Source
Of Sync
24.
Backfill Reruns
Application Code ETL
• Easier to Write • Faster Run Time
• Less Likely to Get Out • Needs an Extract Source
Of Sync
• Handles Duplicates from • REPLACE and INSERT
Multiple Executions ON DUPLICATE KEY
UPDATE
25.
Teed Writes then Backfill
or
Backfill then Teed Writes
26.
Verification by Diff
$ diff_user 111222333
target user row is missing
$ diff_user 123456789
- source.user.address_state = ‘CA’
+ target.user.address_state = ‘NY’
27.
Verification by Diff
COMPARING 200 ROWS From: 111222197
User Id: 111222333
target user row is missing
User Id: 111222345
- source.user.address_state = ‘CA’
+ target.user.address_state = ‘NY’
SUMMARY: total rows with errors: 2/200
29.
Progressive Ramp Up
100% 0%
Source Target
Application Reads
30.
Progressive Ramp Up
99% 1%
Source Target
Application Reads
31.
Progressive Ramp Up
95% 5%
Source Target
Application Reads
32.
Progressive Ramp Up
75% 25%
Source Target
Application Reads
33.
Progressive Ramp Up
0% 100%
Source Target
Application Reads
34.
Ramp Up Example
# global configuration
use_new_tables:
employees: true
percent: 1
# application code
if (enabled(‘use_new_tables’)) {
$result = read_from_target();
} else {
$result = read_from_source();
}
35.
Enabled or Disabled?
• Check cookies if user already assigned
• $enabled = configured threshold > random %
• Store $enabled in a cookie for future requests
36.
Continuous Deployment
• Ramp Up / Ramp Down
• Backfill Fixes
• Need Code Running on Prod
to Proceed
• Makes it Easier
42.
Things to Remove
• Code to use old tables
• Code to switch on configuration
• Configuration
• Drop the old tables... eventually
43.
5 Steps Per Table
1. Create Target Tables
2. Tee Writes
3. Backfill
4. Read from Target Tables
5. Wrap Up
44.
Foundational Principles
• Migrate One Table at a Time
• Progressive Ramp Up
• Data Duplication During Transition
45.
Questions?
• Yes, we’re hiring! Specifically MySQL Ops
http://bit.ly/etsywantsawesome
• http://codeascraft.etsy.com
• http://twitter.com/lapsu
Matthew Graham
Percona Live NYC 2011