SlideShare a Scribd company logo
194B
GETTING 100B METRICS TO DISK
Jonathan Thurman -Site Reliability Engineer
@jthurman42

http://www.flickr.com/photos/meteopassione/9157134653/
NEW RELIC

• Performance Monitoring
• Web Apps
• Mobile Apps
• Servers
• Databases, Caches & More…
• Software Analytics
O K AY, Y O U
C O L L E C T D ATA
• 194 Billion Metrics
• 100,000 req/sec
• 2 Gbps Inbound
• 216 Terabytes
• All backed my MySQL

http://www.flickr.com/photos/bobsfever/6658919861/
HOW WE GOT HERE

http://www.flickr.com/photos/auvet/853157494/
BUILDING BLOCKS

• Hosted Environment
• Xen Virtual Machines
• Data storage
• ATA over Ethernet
• SATA drives
• MySQL 5.0
• Single Ruby on Rails Application
http://www.flickr.com/photos/riekhavoc/4648423297/
SHARDING FROM
INCEPTION
• Account Information
• Read heavy
• Single HA Instance
• Agent Data
• Write heavy
• 8 shards based on AccountId

http://www.flickr.com/photos/erikb/48221952/
TA L E O F 

TWO MODELS

• Ruby on Rails
• class ShardData < ActiveRecord::Base
• Look up shard for Account
• Override ConnectionHandler

http://www.flickr.com/photos/jungle_boy/140279885/
Getting 100B Metrics to Disk
T R I B B L E S TA B L E S

• Metric table name contains
• AccountID
• Year and Julian Day
• Resolution
• ts_72_13221_1h
• Currently ~200k tables per DB

http://www.flickr.com/photos/15942690@N00/4571141076/
BINGE AND PURGE

• Purging data
• DELETE FROM …
• DROP TABLE …
• innodb_file_per_table
• innodb_lazy_drop_table


(pre 5.5.30-30.2)

http://www.flickr.com/photos/exalthim/2261294871/
http://www.flickr.com/photos/heliocentric/1571127347/

http://www.flickr.com/photos/davidmonro/8331755849/

http://www.flickr.com/photos/aigle_dore/6225535459/
G R O W I N G PA I N S

http://www.flickr.com/photos/aigle_dore/5626285743/
M U LT I P L E P O I N T S
O F FA I L U R E

• Single shard slows down
• App servers wait for response
• DB connection pool becomes full
• Site goes down

http://www.flickr.com/photos/boston_public_library/8204384670/
SHARDGUARD

• Monitor all databases
• Identify shard status:
• Bad? Mark as “wedged”
• Good? Clear “wedged” flag
• ShardData checks status!

http://www.flickr.com/photos/mac_filko/5486980804/
S TA B I L I T Y A N D
PERFORMANCE

• Degraded performance
• New Accounts => Shard 9!
• Old accounts remain as-is

http://www.flickr.com/photos/ejpphoto/7823027272/
D ATA C O L L E C T I O N

• Rails isn’t great for data collection
• Ruby isn’t great either…
• Rewritten in Java using Jetty

http://www.flickr.com/photos/autograt/224540606/
http://www.flickr.com/photos/epsos/8474532085/

CACHE IS KING

• Buffered, not queued
• RAM is cheaper than I/O
• Get creative with batch processing
INSERT INTO
(SELECT …

• Select rows and re-process
• Cache last hour in Java’s Heap
• Write a journal and post-process it

http://www.flickr.com/photos/esoteric_13/4741001804/
READ / WRITE
PROBLEM

• Sequential Inserts
• Batched in 5k chunks
• Optimize for Throughput
• Must complete < 1 minute
READ / WRITE
PROBLEM

• Scattered Reads
• Optimized for Latency
• Unique Covering Indexes
MOVE TO
HARDWARE
• Instant performance!
• Just add…
• Datacenter - Chicago, US
• Servers - Dell
• Storage - Direct Attached
• Time - About 6 months

http://www.flickr.com/photos/zebble/9621007/
SPINNING

RUST

• Dell MD1200 shelves
• 8 Disks per shelf
• RAID 5 virtual disk
• Dedicated Hot-spare

http://www.flickr.com/photos/walkn/5472536812/
T H E G R E AT
E X PA N S E

• MD1200s support 12 disks
• Add four more!
• Online RAID expansion

http://www.flickr.com/photos/aigle_dore/5853807037/
# FA I L

• “On-line” expansion, not so much
• Added second 4 disk RAID 5
• LVM Concatenation for space

http://www.flickr.com/photos/fireflythegreat/2845637227/
NEED MORE
C A PA C I T Y

• Tight on disk space
• Performance not an issue
• New Accounts => Shard 10!
• Old Accounts as-is

http://www.flickr.com/photos/seandreilinger/6289721616/
Getting 100B Metrics to Disk
S H A R D P I T FA L L S

http://www.flickr.com/photos/21206761@N00/469110140/
M I G R AT I O N
PROBLEM

• Accounts cannot move
• Not all tables have the shard key
• Rails defaults to auto-increment IDs
• Massive primary key collisions
• Punt and move the metrics

http://www.flickr.com/photos/tzafrir/125380911/
BREAKING UP IS
HARD TO DO

• Agent Databases
• Metadata / Notes / Errors
• Timeslice Databases
• Time-series metric data
• 1 Minute and 1 Hour resolution

http://www.flickr.com/photos/rsepulveda/4275236049/
Getting 100B Metrics to Disk
RESOURCE POOLS

• Distributed by Shard Key
• Distribution can CHANGE
• Lookup table, not hash
• Data can be MOVED

http://www.flickr.com/photos/dclark3996/4971906528/
BACKUPS

• Custom mysqldump wrapper
• Based on business need
• Backup per table
• Ignore tables to be purged

http://www.flickr.com/photos/usdagov/6896218334/
EVOLUTION

http://www.flickr.com/photos/pfsullivan_1056/3485953405/
SSD REVOLUTION

• 600GB Intel 320 SSDs
• Dell MD1220 Direct Attached shelf
• Disks are no longer the bottle-neck
• Inserts in Read-optimized order


are “fast enough”
YOU CAN USE SSD
W I T H D ATA B A S E S

• 6 of 420 drives RMA’d
• March 2012 to Aug 2013
• Average 180TB lifetime writes
• 91% wear remaining

http://www.flickr.com/photos/joeshlabotnik/3584172834/
R E D U N D A N T A R R AY
OF EXPENSIVE DISKS

• Rebuilds under load > 4 hours
• Migrated to RAID 60
• 2 x 12 disk span
• Ditch the Hot-spares

http://www.flickr.com/photos/mbk/27640225/
XFS TUNING

• mkfs.xfs -s size=4096
• options
• noatime
• nobarrier
• inode64
• logbsize=256k

http://www.flickr.com/photos/rocketlass/5169004165/
SHARDGUARD
PA R T D E U X

• Protect all the things!
• Kill UI queries over 75 seconds
• Kill background queries over 1 hour
• Yes, all of them
• No really, kill them, now

http://www.flickr.com/photos/chiky/7194089194/
IF YOU DON’T
BELIEVE ME…

• Delayed Job
• Long running background query
• InnoDB History List Traversal
TO INFINITY AND BEYOND

http://www.flickr.com/photos/temma2/1149223191/
HARDWARE V2

• Dell R620
• 2 x Intel E5-2690 @ 2.90GHz
• 96GB RAM
• MD1220 Storage Shelf
• 800GB Intel SSD S3500

http://www.flickr.com/photos/tnarik/2590037637/
CONTINUOUS

IMPROVEMENT

• EXT4 / ZFS / XFS
• RAID Card vs HBA
• Percona Server 5.6
• Multiple MySQL Instances
• Databases per Service

http://www.flickr.com/photos/shawnclover/8555834230/
JOIN THE TEAM

NewRelic.com/jobs

More Related Content

What's hot (20)

PPT
Windy cityrails performance_tuning
John McCaffrey
 
PDF
Michael North "Ember.js 2 - Future-friendly ambitious apps, that scale!"
Fwdays
 
PDF
PLAT-8 Spring Web Scripts and Spring Surf
Alfresco Software
 
PDF
React.js for Rails Developers
Arkency
 
PDF
Modern javascript
Kevin Ball
 
PDF
React on rails v6.1 at LA Ruby, November 2016
Justin Gordon
 
PDF
Webcomponents are your frameworks best friend
Filip Bruun Bech-Larsen
 
PDF
Frameworks and webcomponents
Filip Bruun Bech-Larsen
 
ODP
Cvcc performance tuning
John McCaffrey
 
PDF
Write Once, Run Everywhere - Ember.js Munich
Mike North
 
PDF
Cloud Native Camel Riding
Christian Posta
 
PDF
Web Development using Ruby on Rails
Avi Kedar
 
KEY
Cloud tools
John McCaffrey
 
PDF
Service-Oriented Design and Implement with Rails3
Wen-Tien Chang
 
PPTX
Best Practices in SharePoint Development - Just Freakin Work! Overcoming Hurd...
Geoff Varosky
 
PDF
Server Check.in case study - Drupal and Node.js
Jeff Geerling
 
PDF
PLAT-7 Spring Web Scripts and Spring Surf
Alfresco Software
 
PDF
KoprowskiT_SQLRelay2014#4_Caerdydd_MaintenancePlansForBeginners
Tobias Koprowski
 
PDF
Web a Quebec - JS Debugging
Rami Sayar
 
PPTX
Agile sites2
Michele Sciabarrà
 
Windy cityrails performance_tuning
John McCaffrey
 
Michael North "Ember.js 2 - Future-friendly ambitious apps, that scale!"
Fwdays
 
PLAT-8 Spring Web Scripts and Spring Surf
Alfresco Software
 
React.js for Rails Developers
Arkency
 
Modern javascript
Kevin Ball
 
React on rails v6.1 at LA Ruby, November 2016
Justin Gordon
 
Webcomponents are your frameworks best friend
Filip Bruun Bech-Larsen
 
Frameworks and webcomponents
Filip Bruun Bech-Larsen
 
Cvcc performance tuning
John McCaffrey
 
Write Once, Run Everywhere - Ember.js Munich
Mike North
 
Cloud Native Camel Riding
Christian Posta
 
Web Development using Ruby on Rails
Avi Kedar
 
Cloud tools
John McCaffrey
 
Service-Oriented Design and Implement with Rails3
Wen-Tien Chang
 
Best Practices in SharePoint Development - Just Freakin Work! Overcoming Hurd...
Geoff Varosky
 
Server Check.in case study - Drupal and Node.js
Jeff Geerling
 
PLAT-7 Spring Web Scripts and Spring Surf
Alfresco Software
 
KoprowskiT_SQLRelay2014#4_Caerdydd_MaintenancePlansForBeginners
Tobias Koprowski
 
Web a Quebec - JS Debugging
Rami Sayar
 
Agile sites2
Michele Sciabarrà
 

Viewers also liked (20)

PDF
Velocity 2013 london developer-friendly web performance testing in continuou...
Michael Klepikov
 
PPTX
Why Page Speed Isn't Enough - Tim Morrow - Velocity Europe 2012
Tim Morrow
 
PDF
Velocity EU 2013 What is the velocity of an unladen swallow?
pdyball
 
PDF
Performance and Metrics at Lonely Planet
Mark Jennings
 
PPTX
Data viz as_interface_makoto_inoue
Makoto Inoue
 
PDF
Are Today’s Good Practices… Tomorrow’s Performance Anti-Patterns?
Andy Davies
 
PDF
Bring the Noise
Jon Cowie
 
PDF
MeasureWorks - Velocity Conference Europe 2012 - a Web Performance dashboard ...
MeasureWorks
 
PPT
Velocity EU 2012 - Third party scripts and you
Patrick Meenan
 
PDF
Be Mean to Your Code with Gauntlt and the Rugged Way // Velocity EU 2013 Work...
James Wickett
 
PDF
Velocity EU 2012 Escalating Scenarios: Outage Handling Pitfalls
John Allspaw
 
PDF
Monitoring and observability
Theo Schlossnagle
 
PPTX
Velocity Europe 2013: Beyond Pretty Charts: Analytics for the cloud infrastru...
tboubez
 
PDF
Hybrid neural networks for time series learning by Tian Guo, EPFL, Switzerland
EuroIoTa
 
PDF
What HTTP/2.0 Will Do For You
Mark Nottingham
 
PPT
Case Study: Realtime Analytics with Druid
Salil Kalia
 
PDF
SaaS Introduction-May2014
Nguyen Tung
 
PDF
Web Page Test - Beyond the Basics
Andy Davies
 
PPTX
HBaseCon 2015: Industrial Internet Case Study using HBase and TSDB
HBaseCon
 
PPTX
Step by Step Mobile Optimization
Guy Podjarny
 
Velocity 2013 london developer-friendly web performance testing in continuou...
Michael Klepikov
 
Why Page Speed Isn't Enough - Tim Morrow - Velocity Europe 2012
Tim Morrow
 
Velocity EU 2013 What is the velocity of an unladen swallow?
pdyball
 
Performance and Metrics at Lonely Planet
Mark Jennings
 
Data viz as_interface_makoto_inoue
Makoto Inoue
 
Are Today’s Good Practices… Tomorrow’s Performance Anti-Patterns?
Andy Davies
 
Bring the Noise
Jon Cowie
 
MeasureWorks - Velocity Conference Europe 2012 - a Web Performance dashboard ...
MeasureWorks
 
Velocity EU 2012 - Third party scripts and you
Patrick Meenan
 
Be Mean to Your Code with Gauntlt and the Rugged Way // Velocity EU 2013 Work...
James Wickett
 
Velocity EU 2012 Escalating Scenarios: Outage Handling Pitfalls
John Allspaw
 
Monitoring and observability
Theo Schlossnagle
 
Velocity Europe 2013: Beyond Pretty Charts: Analytics for the cloud infrastru...
tboubez
 
Hybrid neural networks for time series learning by Tian Guo, EPFL, Switzerland
EuroIoTa
 
What HTTP/2.0 Will Do For You
Mark Nottingham
 
Case Study: Realtime Analytics with Druid
Salil Kalia
 
SaaS Introduction-May2014
Nguyen Tung
 
Web Page Test - Beyond the Basics
Andy Davies
 
HBaseCon 2015: Industrial Internet Case Study using HBase and TSDB
HBaseCon
 
Step by Step Mobile Optimization
Guy Podjarny
 
Ad

Similar to Getting 100B Metrics to Disk (20)

PDF
Re-inventing the Database: What to Keep and What to Throw Away
DATAVERSITY
 
PPTX
Handling Massive Writes
Liran Zelkha
 
PDF
Cloudcon East Presentation
br7tt
 
PDF
Cloudcon East Presentation
br7tt
 
PPTX
Best storage engine for MySQL
tomflemingh2
 
PDF
5 Steps to PostgreSQL Performance
Command Prompt., Inc
 
PDF
Five steps perform_2009 (1)
PostgreSQL Experts, Inc.
 
PDF
2008 MySQL Conference Recap
Chris Barber
 
PDF
High-Performance Storage Services with HailDB and Java
sunnygleason
 
PDF
The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin
Dave Stokes
 
PDF
Storage Methods for Nonstandard Data Patterns
Bob Burgess
 
PDF
MySQL Storage Engines Landscape
Colin Charles
 
PDF
Performance Whack A Mole
oscon2007
 
PDF
Linuxfest Northwest Proper Care and Feeding Of a MySQL for Busy Linux Admins
Dave Stokes
 
PDF
Mysql features for the enterprise
Giuseppe Maxia
 
PPTX
Presentation db2 best practices for optimal performance
solarisyougood
 
PDF
Your backend architecture is what matters slideshare
Colin Charles
 
PDF
My Sql And Search At Craigslist
MySQLConference
 
PDF
Presentation db2 best practices for optimal performance
xKinAnx
 
PDF
Proper Care and Feeding of a MySQL Database for Busy Linux Administrators
Dave Stokes
 
Re-inventing the Database: What to Keep and What to Throw Away
DATAVERSITY
 
Handling Massive Writes
Liran Zelkha
 
Cloudcon East Presentation
br7tt
 
Cloudcon East Presentation
br7tt
 
Best storage engine for MySQL
tomflemingh2
 
5 Steps to PostgreSQL Performance
Command Prompt., Inc
 
Five steps perform_2009 (1)
PostgreSQL Experts, Inc.
 
2008 MySQL Conference Recap
Chris Barber
 
High-Performance Storage Services with HailDB and Java
sunnygleason
 
The Peoper Care and Feeding of a MySQL Server for Busy Linux Admin
Dave Stokes
 
Storage Methods for Nonstandard Data Patterns
Bob Burgess
 
MySQL Storage Engines Landscape
Colin Charles
 
Performance Whack A Mole
oscon2007
 
Linuxfest Northwest Proper Care and Feeding Of a MySQL for Busy Linux Admins
Dave Stokes
 
Mysql features for the enterprise
Giuseppe Maxia
 
Presentation db2 best practices for optimal performance
solarisyougood
 
Your backend architecture is what matters slideshare
Colin Charles
 
My Sql And Search At Craigslist
MySQLConference
 
Presentation db2 best practices for optimal performance
xKinAnx
 
Proper Care and Feeding of a MySQL Database for Busy Linux Administrators
Dave Stokes
 
Ad

Recently uploaded (20)

PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Biography of Daniel Podor.pdf
Daniel Podor
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 

Getting 100B Metrics to Disk

  • 1. 194B GETTING 100B METRICS TO DISK Jonathan Thurman -Site Reliability Engineer @jthurman42 http://www.flickr.com/photos/meteopassione/9157134653/
  • 2. NEW RELIC • Performance Monitoring • Web Apps • Mobile Apps • Servers • Databases, Caches & More… • Software Analytics
  • 3. O K AY, Y O U C O L L E C T D ATA • 194 Billion Metrics • 100,000 req/sec • 2 Gbps Inbound • 216 Terabytes • All backed my MySQL http://www.flickr.com/photos/bobsfever/6658919861/
  • 4. HOW WE GOT HERE http://www.flickr.com/photos/auvet/853157494/
  • 5. BUILDING BLOCKS • Hosted Environment • Xen Virtual Machines • Data storage • ATA over Ethernet • SATA drives • MySQL 5.0 • Single Ruby on Rails Application http://www.flickr.com/photos/riekhavoc/4648423297/
  • 6. SHARDING FROM INCEPTION • Account Information • Read heavy • Single HA Instance • Agent Data • Write heavy • 8 shards based on AccountId http://www.flickr.com/photos/erikb/48221952/
  • 7. TA L E O F 
 TWO MODELS • Ruby on Rails • class ShardData < ActiveRecord::Base • Look up shard for Account • Override ConnectionHandler http://www.flickr.com/photos/jungle_boy/140279885/
  • 9. T R I B B L E S TA B L E S • Metric table name contains • AccountID • Year and Julian Day • Resolution • ts_72_13221_1h • Currently ~200k tables per DB http://www.flickr.com/photos/15942690@N00/4571141076/
  • 10. BINGE AND PURGE • Purging data • DELETE FROM … • DROP TABLE … • innodb_file_per_table • innodb_lazy_drop_table
 (pre 5.5.30-30.2) http://www.flickr.com/photos/exalthim/2261294871/
  • 12. G R O W I N G PA I N S http://www.flickr.com/photos/aigle_dore/5626285743/
  • 13. M U LT I P L E P O I N T S O F FA I L U R E • Single shard slows down • App servers wait for response • DB connection pool becomes full • Site goes down http://www.flickr.com/photos/boston_public_library/8204384670/
  • 14. SHARDGUARD • Monitor all databases • Identify shard status: • Bad? Mark as “wedged” • Good? Clear “wedged” flag • ShardData checks status! http://www.flickr.com/photos/mac_filko/5486980804/
  • 15. S TA B I L I T Y A N D PERFORMANCE • Degraded performance • New Accounts => Shard 9! • Old accounts remain as-is http://www.flickr.com/photos/ejpphoto/7823027272/
  • 16. D ATA C O L L E C T I O N • Rails isn’t great for data collection • Ruby isn’t great either… • Rewritten in Java using Jetty http://www.flickr.com/photos/autograt/224540606/
  • 17. http://www.flickr.com/photos/epsos/8474532085/ CACHE IS KING • Buffered, not queued • RAM is cheaper than I/O • Get creative with batch processing
  • 18. INSERT INTO (SELECT … • Select rows and re-process • Cache last hour in Java’s Heap • Write a journal and post-process it http://www.flickr.com/photos/esoteric_13/4741001804/
  • 19. READ / WRITE PROBLEM • Sequential Inserts • Batched in 5k chunks • Optimize for Throughput • Must complete < 1 minute
  • 20. READ / WRITE PROBLEM • Scattered Reads • Optimized for Latency • Unique Covering Indexes
  • 21. MOVE TO HARDWARE • Instant performance! • Just add… • Datacenter - Chicago, US • Servers - Dell • Storage - Direct Attached • Time - About 6 months http://www.flickr.com/photos/zebble/9621007/
  • 22. SPINNING
 RUST • Dell MD1200 shelves • 8 Disks per shelf • RAID 5 virtual disk • Dedicated Hot-spare http://www.flickr.com/photos/walkn/5472536812/
  • 23. T H E G R E AT E X PA N S E • MD1200s support 12 disks • Add four more! • Online RAID expansion http://www.flickr.com/photos/aigle_dore/5853807037/
  • 24. # FA I L • “On-line” expansion, not so much • Added second 4 disk RAID 5 • LVM Concatenation for space http://www.flickr.com/photos/fireflythegreat/2845637227/
  • 25. NEED MORE C A PA C I T Y • Tight on disk space • Performance not an issue • New Accounts => Shard 10! • Old Accounts as-is http://www.flickr.com/photos/seandreilinger/6289721616/
  • 27. S H A R D P I T FA L L S http://www.flickr.com/photos/21206761@N00/469110140/
  • 28. M I G R AT I O N PROBLEM • Accounts cannot move • Not all tables have the shard key • Rails defaults to auto-increment IDs • Massive primary key collisions • Punt and move the metrics http://www.flickr.com/photos/tzafrir/125380911/
  • 29. BREAKING UP IS HARD TO DO • Agent Databases • Metadata / Notes / Errors • Timeslice Databases • Time-series metric data • 1 Minute and 1 Hour resolution http://www.flickr.com/photos/rsepulveda/4275236049/
  • 31. RESOURCE POOLS • Distributed by Shard Key • Distribution can CHANGE • Lookup table, not hash • Data can be MOVED http://www.flickr.com/photos/dclark3996/4971906528/
  • 32. BACKUPS • Custom mysqldump wrapper • Based on business need • Backup per table • Ignore tables to be purged http://www.flickr.com/photos/usdagov/6896218334/
  • 34. SSD REVOLUTION • 600GB Intel 320 SSDs • Dell MD1220 Direct Attached shelf • Disks are no longer the bottle-neck • Inserts in Read-optimized order
 are “fast enough”
  • 35. YOU CAN USE SSD W I T H D ATA B A S E S • 6 of 420 drives RMA’d • March 2012 to Aug 2013 • Average 180TB lifetime writes • 91% wear remaining http://www.flickr.com/photos/joeshlabotnik/3584172834/
  • 36. R E D U N D A N T A R R AY OF EXPENSIVE DISKS • Rebuilds under load > 4 hours • Migrated to RAID 60 • 2 x 12 disk span • Ditch the Hot-spares http://www.flickr.com/photos/mbk/27640225/
  • 37. XFS TUNING • mkfs.xfs -s size=4096 • options • noatime • nobarrier • inode64 • logbsize=256k http://www.flickr.com/photos/rocketlass/5169004165/
  • 38. SHARDGUARD PA R T D E U X • Protect all the things! • Kill UI queries over 75 seconds • Kill background queries over 1 hour • Yes, all of them • No really, kill them, now http://www.flickr.com/photos/chiky/7194089194/
  • 39. IF YOU DON’T BELIEVE ME… • Delayed Job • Long running background query • InnoDB History List Traversal
  • 40. TO INFINITY AND BEYOND http://www.flickr.com/photos/temma2/1149223191/
  • 41. HARDWARE V2 • Dell R620 • 2 x Intel E5-2690 @ 2.90GHz • 96GB RAM • MD1220 Storage Shelf • 800GB Intel SSD S3500 http://www.flickr.com/photos/tnarik/2590037637/
  • 42. CONTINUOUS
 IMPROVEMENT • EXT4 / ZFS / XFS • RAID Card vs HBA • Percona Server 5.6 • Multiple MySQL Instances • Databases per Service http://www.flickr.com/photos/shawnclover/8555834230/