SlideShare a Scribd company logo
1 of 30
Download to read offline
Using MySQL in a
web-scale environment
David Landgren (@dlandgren, david@landgren.net)
Percona Live Europe Amsterdam
September 21-23, 2015
Some facts and figures
Video hosting platform
10 years old
300 billion+ video views per month
400 million+ unique visitors per month
34th largest site world wide (comScore)
Largest European site with global reach
Classic LAMP Architecture
Linux (1400 servers)
Apache (250 servers)
Mysql (70 servers)
PHP
12 clusters
Limited use of horizontal partitioning
Percona 5.6 used (nearly) everywhere
InnoDB used (nearly) everywhere
No foreign keys or referential integrity
Primary cluster
2 master servers for writes
25 slaves for reads
Additional slaves for special purposes (backups, devs)
Vertical partitioning, no sharding
No query cache
Managing the farm
Apache ZooKeeper / zkfarmer
Slaves announce their presence in the farm
PHP framework is automatically aware (on next request)
https://github.com/rs/zkfarmer	
  
Performance
Memcache deflects 10x more queries
Nearly all reads on PK
Organic growth in "slow" queries
count(*) still hurts us
Blindly kill long running queries
All your base are optimized
How do we avoid fragmentation?
Perform rolling optimize	
  table	
  <foo> across the
schema we care about
Take an ordinary slave out of production, copy the latest
backup over, and send it back into production
	
  
Perform regular backups on a dedicated slave (Percona
Xtrabackup)
Spread the love
Spread the love^Wload
Slaves have a nominal weight (probability to be selected for
a given HTTP connection)
0
50
0.25
lag
weight
p
0
50
0.25
0
50
0.25
0
50
0.25
∑=200
Spread the load
Reduce production pressure on slaves that are not keeping
up with the replication from master
0
50
0.3125
lag
weight
p
0
50
0.3125
0
50
0.3125
120
10
0.0625
∑=160
Slow queries
Percona has some interesting parameters for managing
slow logs
§  log_slow_filter
§  log_slow_rate_limit
pt-query-digest <logfile>
Read the results regularly
Worst. Query. Ever.
SELECT	
  foo.foo_id	
  AS	
  id	
  FROM	
  foo	
  
INNER	
  JOIN	
  (	
  
	
  	
  	
  	
  SELECT	
  foo.foo_id	
  
	
  	
  	
  	
  FROM	
  foo	
  
	
  	
  	
  	
  INNER	
  JOIN	
  bar_quux	
  bar_gonk	
  ON	
  (bar_gonk.label	
  =	
  'splak'	
  AND	
  bar_gonk.value	
  =	
  'skroom')	
  
	
  	
  	
  	
  INNER	
  JOIN	
  foo_quux	
  foo_gonk	
  ON	
  (foo_gonk.label	
  =	
  'fwask'	
  AND	
  foo_gonk.value	
  =	
  'florf')	
  
	
  	
  	
  	
  INNER	
  JOIN	
  bar_has_quux	
  is_bar_gonk	
  ON	
  
	
  	
  	
  	
  	
  	
  	
  	
  (is_bar_gonk.bar_quux_id	
  =	
  bar_gonk.bar_quux_id	
  AND	
  is_bar_gonk.bar_id	
  =	
  foo.bar_id)	
  
	
  	
  	
  	
  INNER	
  JOIN	
  foo_has_quux	
  is_foo_gonk	
  ON	
  
	
  	
  	
  	
  	
  	
  	
  	
  (is_foo_gonk.foo_quux_id	
  =	
  foo_gonk.foo_quux_id	
  AND	
  is_foo_gonk.foo_id	
  =	
  foo.foo_id)	
  
	
  	
  	
  	
  UNION	
  
	
  	
  	
  	
  	
  	
  	
  	
  SELECT	
  baz.foo_id	
  FROM	
  baz	
  WHERE	
  baz.value	
  >	
  0	
  
)	
  X	
  ON	
  (X.foo_id	
  =	
  foo.foo_id)	
  
LEFT	
  JOIN	
  foo_has_fliff	
  zwot	
  ON	
  (zwot.foo_id	
  =	
  foo.foo_id	
  AND	
  zwot.foo_fliff_id	
  =	
  246)	
  
INNER	
  JOIN	
  foo_quux	
  bleep	
  ON	
  (bleep.label	
  =	
  'blort-­‐allow'	
  AND	
  bleep.value	
  =	
  'thlip')	
  
LEFT	
  JOIN	
  foo_quux	
  bap	
  ON	
  (bap.label	
  =	
  'blort'	
  AND	
  bap.value	
  =	
  'ba')	
  
LEFT	
  JOIN	
  foo_has_quux	
  blif	
  ON	
  (blif.foo_id	
  =	
  foo.foo_id	
  AND	
  blif.foo_quux_id	
  =	
  bap.foo_quux_id)	
  
LEFT	
  JOIN	
  foo_has_quux	
  fweep	
  ON	
  (fweep.foo_id	
  =	
  foo.foo_id	
  AND	
  fweep.foo_quux_id	
  =	
  bleep.foo_quux_id)	
  
WHERE	
  foo.a	
  =	
  1	
  AND	
  foo.b	
  =	
  0	
  AND	
  foo.c	
  =	
  0	
  AND	
  foo.d	
  =	
  0	
  AND	
  foo.e	
  =	
  0	
  AND	
  foo.f	
  =	
  0	
  AND	
  foo.g	
  =	
  1	
  
	
  	
  	
  	
  AND	
  foo.bar_id	
  =	
  12345	
  
	
  	
  	
  	
  AND	
  zwot.foo_fliff_id	
  IS	
  NULL	
  
	
  	
  	
  	
  AND	
  NOT	
  (blif.foo_id	
  IS	
  NULL	
  XOR	
  fweep.foo_id	
  IS	
  NULL)	
  
ORDER	
  BY	
  foo.tink	
  DESC	
  
Slow queries
Keep an eye on their evolution
https://github.com/box/Anemometer	
  
Analyze slow query logs to identify problematic queries
Slow queries
REALLY slow queries
REALLY slow queries
Save your platform, kill them
github.com/dailymotion/mysql-­‐genocide	
  
Graph the effects
Watching technical debt
Information_schema.table_statistics
SELECT	
  t.table_name,	
  s.rows_read	
  
FROM	
  information_schema.tables	
  t	
  
LEFT	
  JOIN	
  information_schema.table_statistics	
  s	
  
	
  	
  	
  ON	
  (t.table_schema	
  =	
  s.table_schema	
  
	
  	
  	
  	
  	
  	
  	
  	
  and	
  t.table_name	
  =	
  s.table_name)	
  
WHERE	
  
	
  	
  	
  	
  t.table_schema	
  =	
  'myschema'	
  
	
  	
  	
  	
  AND	
  coalesce(rows_read,	
  0)	
  =	
  0	
  
ORDER	
  BY	
  1;	
  
Watching technical debt
Unused indices
SELECT	
  DISTINCT	
  t.table_name,	
  t.index_name,	
  s.rows_read	
  
FROM	
  statistics	
  t	
  
LEFT	
  JOIN	
  index_statistics	
  s	
  
	
  	
  	
  	
  USING	
  (table_schema,	
  table_name,	
  index_name)	
  
WHERE	
  t.table_schema	
  =	
  'myschema'	
  
	
  	
  	
  	
  AND	
  coalesce(s.rows_read,	
  0)	
  =	
  0	
  
ORDER	
  BY	
  1,	
  2;	
  
	
  
Managing change
https://github.com/outbrain/propagator	
  
All schema changes are logged (and recorded in git)
Managing change (2)
Percona Online Schema Change
https://www.percona.com/doc/percona-­‐toolkit/2.1/
pt-­‐online-­‐schema-­‐change.html	
  
Future Directions
Global Transaction ID (GTID)
Parallel replication
Multiple source replication
Thank you!
David Landgren
(dland@github, @dlandgren)
david@landgren.net
Acknowledgements
All photos by Gézelin Grée
gezelingree.com / 10000lux.blogspot.com	
  
Comic drawn by Randall Munroe / xkcd.com	
  

More Related Content

What's hot

2013 april gruff webinar san diego copy
2013 april  gruff webinar   san diego copy2013 april  gruff webinar   san diego copy
2013 april gruff webinar san diego copyBarbaraStarr2009
 
2013 april gruff webinar san diego copy
2013 april  gruff webinar   san diego copy2013 april  gruff webinar   san diego copy
2013 april gruff webinar san diego copyBarbaraStarr2009
 
Development and practical use of CLI in perl 6
Development and practical use of CLI in perl 6Development and practical use of CLI in perl 6
Development and practical use of CLI in perl 6risou
 
Next Generation Sequencing file Formats ( 2017 )
Next Generation Sequencing file Formats ( 2017 )Next Generation Sequencing file Formats ( 2017 )
Next Generation Sequencing file Formats ( 2017 )Pierre Lindenbaum
 
Files in c
Files in cFiles in c
Files in cTanujaA3
 
Building custom sections in Umbraco
Building custom sections in UmbracoBuilding custom sections in Umbraco
Building custom sections in Umbracodawoe
 
Missing kids on you
Missing kids on youMissing kids on you
Missing kids on youguest3fa681
 

What's hot (10)

2013 april gruff webinar san diego copy
2013 april  gruff webinar   san diego copy2013 april  gruff webinar   san diego copy
2013 april gruff webinar san diego copy
 
2013 april gruff webinar san diego copy
2013 april  gruff webinar   san diego copy2013 april  gruff webinar   san diego copy
2013 april gruff webinar san diego copy
 
PHPTAL with CakePHP
PHPTAL with CakePHPPHPTAL with CakePHP
PHPTAL with CakePHP
 
Development and practical use of CLI in perl 6
Development and practical use of CLI in perl 6Development and practical use of CLI in perl 6
Development and practical use of CLI in perl 6
 
Next Generation Sequencing file Formats ( 2017 )
Next Generation Sequencing file Formats ( 2017 )Next Generation Sequencing file Formats ( 2017 )
Next Generation Sequencing file Formats ( 2017 )
 
Files in c
Files in cFiles in c
Files in c
 
CompilersAndLibraries
CompilersAndLibrariesCompilersAndLibraries
CompilersAndLibraries
 
Duug - Ttypescript
Duug - TtypescriptDuug - Ttypescript
Duug - Ttypescript
 
Building custom sections in Umbraco
Building custom sections in UmbracoBuilding custom sections in Umbraco
Building custom sections in Umbraco
 
Missing kids on you
Missing kids on youMissing kids on you
Missing kids on you
 

Viewers also liked

MySQL Cluster Scaling to a Billion Queries
MySQL Cluster Scaling to a Billion QueriesMySQL Cluster Scaling to a Billion Queries
MySQL Cluster Scaling to a Billion QueriesBernd Ocklin
 
Jupa_SolidCitric_products
Jupa_SolidCitric_productsJupa_SolidCitric_products
Jupa_SolidCitric_productsEndre Birkeland
 
MetLife reaches settlement in lawsuit over alleged improper sales | CJOnline.com
MetLife reaches settlement in lawsuit over alleged improper sales | CJOnline.comMetLife reaches settlement in lawsuit over alleged improper sales | CJOnline.com
MetLife reaches settlement in lawsuit over alleged improper sales | CJOnline.comPaula Story
 
LLM - Developing Your Network
LLM - Developing Your NetworkLLM - Developing Your Network
LLM - Developing Your NetworkGreg Cohen
 
Trabajo practico n° 3
Trabajo practico n° 3Trabajo practico n° 3
Trabajo practico n° 3Jessy Lopez
 
500225_AWC Newsletter_Volume 3_FINAL_7-1-14
500225_AWC Newsletter_Volume 3_FINAL_7-1-14500225_AWC Newsletter_Volume 3_FINAL_7-1-14
500225_AWC Newsletter_Volume 3_FINAL_7-1-14Shawn Groth
 
статья ПРИЗМА сверкает гранями
статья ПРИЗМА сверкает гранямистатья ПРИЗМА сверкает гранями
статья ПРИЗМА сверкает гранямиРома Алексеев
 
Sales Manager-Chippy Simumba
Sales Manager-Chippy SimumbaSales Manager-Chippy Simumba
Sales Manager-Chippy SimumbaChippy Simumba
 
evaluation and outline of key changes and implementations
evaluation and outline of key changes and implementationsevaluation and outline of key changes and implementations
evaluation and outline of key changes and implementationscseerussell
 
Master mx 55a edicion
Master mx 55a edicionMaster mx 55a edicion
Master mx 55a edicionMaster Mx
 
Audience Research
Audience Research Audience Research
Audience Research JacobDMBird
 
Master mx 28ª edicion
Master mx 28ª edicionMaster mx 28ª edicion
Master mx 28ª edicionMaster Mx
 
ENG3305_Adv_Essay_Writing_gay_men_and_barebacking
ENG3305_Adv_Essay_Writing_gay_men_and_barebackingENG3305_Adv_Essay_Writing_gay_men_and_barebacking
ENG3305_Adv_Essay_Writing_gay_men_and_barebackingEric Roberson
 

Viewers also liked (20)

MySQL Cluster Scaling to a Billion Queries
MySQL Cluster Scaling to a Billion QueriesMySQL Cluster Scaling to a Billion Queries
MySQL Cluster Scaling to a Billion Queries
 
E.B.M. Diploma
E.B.M. DiplomaE.B.M. Diploma
E.B.M. Diploma
 
Jupa_SolidCitric_products
Jupa_SolidCitric_productsJupa_SolidCitric_products
Jupa_SolidCitric_products
 
nift some work
nift some worknift some work
nift some work
 
DCHQ
DCHQDCHQ
DCHQ
 
folasade resume 3
folasade resume 3folasade resume 3
folasade resume 3
 
MetLife reaches settlement in lawsuit over alleged improper sales | CJOnline.com
MetLife reaches settlement in lawsuit over alleged improper sales | CJOnline.comMetLife reaches settlement in lawsuit over alleged improper sales | CJOnline.com
MetLife reaches settlement in lawsuit over alleged improper sales | CJOnline.com
 
LLM - Developing Your Network
LLM - Developing Your NetworkLLM - Developing Your Network
LLM - Developing Your Network
 
Trabajo practico n° 3
Trabajo practico n° 3Trabajo practico n° 3
Trabajo practico n° 3
 
NONDUMISO PORTIA MSELEKU
NONDUMISO PORTIA MSELEKUNONDUMISO PORTIA MSELEKU
NONDUMISO PORTIA MSELEKU
 
500225_AWC Newsletter_Volume 3_FINAL_7-1-14
500225_AWC Newsletter_Volume 3_FINAL_7-1-14500225_AWC Newsletter_Volume 3_FINAL_7-1-14
500225_AWC Newsletter_Volume 3_FINAL_7-1-14
 
Portfolio_2015
Portfolio_2015Portfolio_2015
Portfolio_2015
 
статья ПРИЗМА сверкает гранями
статья ПРИЗМА сверкает гранямистатья ПРИЗМА сверкает гранями
статья ПРИЗМА сверкает гранями
 
Sales Manager-Chippy Simumba
Sales Manager-Chippy SimumbaSales Manager-Chippy Simumba
Sales Manager-Chippy Simumba
 
evaluation and outline of key changes and implementations
evaluation and outline of key changes and implementationsevaluation and outline of key changes and implementations
evaluation and outline of key changes and implementations
 
Master mx 55a edicion
Master mx 55a edicionMaster mx 55a edicion
Master mx 55a edicion
 
Video worksheet
Video worksheetVideo worksheet
Video worksheet
 
Audience Research
Audience Research Audience Research
Audience Research
 
Master mx 28ª edicion
Master mx 28ª edicionMaster mx 28ª edicion
Master mx 28ª edicion
 
ENG3305_Adv_Essay_Writing_gay_men_and_barebacking
ENG3305_Adv_Essay_Writing_gay_men_and_barebackingENG3305_Adv_Essay_Writing_gay_men_and_barebacking
ENG3305_Adv_Essay_Writing_gay_men_and_barebacking
 

Similar to Using MySQL in a web-scale environment

Ruby on Rails: Tasty Burgers
Ruby on Rails: Tasty BurgersRuby on Rails: Tasty Burgers
Ruby on Rails: Tasty BurgersAaron Patterson
 
扩展世界上最大的图片Blog社区
扩展世界上最大的图片Blog社区扩展世界上最大的图片Blog社区
扩展世界上最大的图片Blog社区yiditushe
 
Fotolog: Scaling the World's Largest Photo Blogging Community
Fotolog: Scaling the World's Largest Photo Blogging CommunityFotolog: Scaling the World's Largest Photo Blogging Community
Fotolog: Scaling the World's Largest Photo Blogging Communityfarhan "Frank"​ mashraqi
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeWim Godden
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeWim Godden
 
More Data, More Problems: Evolving big data machine learning pipelines with S...
More Data, More Problems: Evolving big data machine learning pipelines with S...More Data, More Problems: Evolving big data machine learning pipelines with S...
More Data, More Problems: Evolving big data machine learning pipelines with S...Alex Sadovsky
 
Greyhound - Powerful Functional Kafka Library - Devtalks reimagined
Greyhound - Powerful Functional Kafka Library - Devtalks reimaginedGreyhound - Powerful Functional Kafka Library - Devtalks reimagined
Greyhound - Powerful Functional Kafka Library - Devtalks reimaginedNatan Silnitsky
 
Cassandra Community Webinar - Introduction To Apache Cassandra 1.2
Cassandra Community Webinar  - Introduction To Apache Cassandra 1.2Cassandra Community Webinar  - Introduction To Apache Cassandra 1.2
Cassandra Community Webinar - Introduction To Apache Cassandra 1.2aaronmorton
 
Cassandra Community Webinar | Introduction to Apache Cassandra 1.2
Cassandra Community Webinar | Introduction to Apache Cassandra 1.2Cassandra Community Webinar | Introduction to Apache Cassandra 1.2
Cassandra Community Webinar | Introduction to Apache Cassandra 1.2DataStax
 
BlueHat Seattle 2019 || Modern Binary Analysis with ILs
BlueHat Seattle 2019 || Modern Binary Analysis with ILsBlueHat Seattle 2019 || Modern Binary Analysis with ILs
BlueHat Seattle 2019 || Modern Binary Analysis with ILsBlueHat Security Conference
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeWim Godden
 
Beyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the codeBeyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the codeWim Godden
 
Adaptive Query Processing on RAW Data
Adaptive Query Processing on RAW DataAdaptive Query Processing on RAW Data
Adaptive Query Processing on RAW DataManos Karpathiotakis
 
ZFConf 2011: Что такое Sphinx, зачем он вообще нужен и как его использовать с...
ZFConf 2011: Что такое Sphinx, зачем он вообще нужен и как его использовать с...ZFConf 2011: Что такое Sphinx, зачем он вообще нужен и как его использовать с...
ZFConf 2011: Что такое Sphinx, зачем он вообще нужен и как его использовать с...ZFConf Conference
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeWim Godden
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeWim Godden
 
Impala: A Modern, Open-Source SQL Engine for Hadoop
Impala: A Modern, Open-Source SQL Engine for HadoopImpala: A Modern, Open-Source SQL Engine for Hadoop
Impala: A Modern, Open-Source SQL Engine for HadoopAll Things Open
 

Similar to Using MySQL in a web-scale environment (20)

Having Fun Programming!
Having Fun Programming!Having Fun Programming!
Having Fun Programming!
 
Ruby on Rails: Tasty Burgers
Ruby on Rails: Tasty BurgersRuby on Rails: Tasty Burgers
Ruby on Rails: Tasty Burgers
 
扩展世界上最大的图片Blog社区
扩展世界上最大的图片Blog社区扩展世界上最大的图片Blog社区
扩展世界上最大的图片Blog社区
 
Fotolog: Scaling the World's Largest Photo Blogging Community
Fotolog: Scaling the World's Largest Photo Blogging CommunityFotolog: Scaling the World's Largest Photo Blogging Community
Fotolog: Scaling the World's Largest Photo Blogging Community
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
 
More Data, More Problems: Evolving big data machine learning pipelines with S...
More Data, More Problems: Evolving big data machine learning pipelines with S...More Data, More Problems: Evolving big data machine learning pipelines with S...
More Data, More Problems: Evolving big data machine learning pipelines with S...
 
Greyhound - Powerful Functional Kafka Library - Devtalks reimagined
Greyhound - Powerful Functional Kafka Library - Devtalks reimaginedGreyhound - Powerful Functional Kafka Library - Devtalks reimagined
Greyhound - Powerful Functional Kafka Library - Devtalks reimagined
 
Cassandra Community Webinar - Introduction To Apache Cassandra 1.2
Cassandra Community Webinar  - Introduction To Apache Cassandra 1.2Cassandra Community Webinar  - Introduction To Apache Cassandra 1.2
Cassandra Community Webinar - Introduction To Apache Cassandra 1.2
 
Cassandra Community Webinar | Introduction to Apache Cassandra 1.2
Cassandra Community Webinar | Introduction to Apache Cassandra 1.2Cassandra Community Webinar | Introduction to Apache Cassandra 1.2
Cassandra Community Webinar | Introduction to Apache Cassandra 1.2
 
BlueHat Seattle 2019 || Modern Binary Analysis with ILs
BlueHat Seattle 2019 || Modern Binary Analysis with ILsBlueHat Seattle 2019 || Modern Binary Analysis with ILs
BlueHat Seattle 2019 || Modern Binary Analysis with ILs
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
 
Beyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the codeBeyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the code
 
Adaptive Query Processing on RAW Data
Adaptive Query Processing on RAW DataAdaptive Query Processing on RAW Data
Adaptive Query Processing on RAW Data
 
ZFConf 2011: Что такое Sphinx, зачем он вообще нужен и как его использовать с...
ZFConf 2011: Что такое Sphinx, зачем он вообще нужен и как его использовать с...ZFConf 2011: Что такое Sphinx, зачем он вообще нужен и как его использовать с...
ZFConf 2011: Что такое Sphinx, зачем он вообще нужен и как его использовать с...
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
 
Solr @ Etsy - Apache Lucene Eurocon
Solr @ Etsy - Apache Lucene EuroconSolr @ Etsy - Apache Lucene Eurocon
Solr @ Etsy - Apache Lucene Eurocon
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
 
Impala: A Modern, Open-Source SQL Engine for Hadoop
Impala: A Modern, Open-Source SQL Engine for HadoopImpala: A Modern, Open-Source SQL Engine for Hadoop
Impala: A Modern, Open-Source SQL Engine for Hadoop
 
01 linux basics
01 linux basics01 linux basics
01 linux basics
 

Recently uploaded

Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...aditipandeya
 
Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girlsstephieert
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxellan12
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGAPNIC
 
Gram Darshan PPT cyber rural in villages of india
Gram Darshan PPT cyber rural  in villages of indiaGram Darshan PPT cyber rural  in villages of india
Gram Darshan PPT cyber rural in villages of indiaimessage0108
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Delhi Call girls
 
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With RoomVIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Roomdivyansh0kumar0
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts servicevipmodelshub1
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebJames Anderson
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607dollysharma2066
 
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$kojalkojal131
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...Diya Sharma
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Sheetaleventcompany
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Roomdivyansh0kumar0
 

Recently uploaded (20)

Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
 
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
 
Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girls
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOG
 
Gram Darshan PPT cyber rural in villages of india
Gram Darshan PPT cyber rural  in villages of indiaGram Darshan PPT cyber rural  in villages of india
Gram Darshan PPT cyber rural in villages of india
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
 
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With RoomVIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
 
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
 
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
 
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 

Using MySQL in a web-scale environment

  • 1. Using MySQL in a web-scale environment David Landgren (@dlandgren, david@landgren.net) Percona Live Europe Amsterdam September 21-23, 2015
  • 2.
  • 3. Some facts and figures Video hosting platform 10 years old 300 billion+ video views per month 400 million+ unique visitors per month 34th largest site world wide (comScore) Largest European site with global reach
  • 4. Classic LAMP Architecture Linux (1400 servers) Apache (250 servers) Mysql (70 servers) PHP
  • 5. 12 clusters Limited use of horizontal partitioning Percona 5.6 used (nearly) everywhere InnoDB used (nearly) everywhere No foreign keys or referential integrity
  • 6.
  • 7. Primary cluster 2 master servers for writes 25 slaves for reads Additional slaves for special purposes (backups, devs) Vertical partitioning, no sharding No query cache
  • 8.
  • 9. Managing the farm Apache ZooKeeper / zkfarmer Slaves announce their presence in the farm PHP framework is automatically aware (on next request) https://github.com/rs/zkfarmer  
  • 10.
  • 11. Performance Memcache deflects 10x more queries Nearly all reads on PK Organic growth in "slow" queries count(*) still hurts us Blindly kill long running queries
  • 12.
  • 13. All your base are optimized How do we avoid fragmentation? Perform rolling optimize  table  <foo> across the schema we care about Take an ordinary slave out of production, copy the latest backup over, and send it back into production   Perform regular backups on a dedicated slave (Percona Xtrabackup)
  • 15. Spread the love^Wload Slaves have a nominal weight (probability to be selected for a given HTTP connection) 0 50 0.25 lag weight p 0 50 0.25 0 50 0.25 0 50 0.25 ∑=200
  • 16. Spread the load Reduce production pressure on slaves that are not keeping up with the replication from master 0 50 0.3125 lag weight p 0 50 0.3125 0 50 0.3125 120 10 0.0625 ∑=160
  • 17. Slow queries Percona has some interesting parameters for managing slow logs §  log_slow_filter §  log_slow_rate_limit pt-query-digest <logfile> Read the results regularly
  • 18. Worst. Query. Ever. SELECT  foo.foo_id  AS  id  FROM  foo   INNER  JOIN  (          SELECT  foo.foo_id          FROM  foo          INNER  JOIN  bar_quux  bar_gonk  ON  (bar_gonk.label  =  'splak'  AND  bar_gonk.value  =  'skroom')          INNER  JOIN  foo_quux  foo_gonk  ON  (foo_gonk.label  =  'fwask'  AND  foo_gonk.value  =  'florf')          INNER  JOIN  bar_has_quux  is_bar_gonk  ON                  (is_bar_gonk.bar_quux_id  =  bar_gonk.bar_quux_id  AND  is_bar_gonk.bar_id  =  foo.bar_id)          INNER  JOIN  foo_has_quux  is_foo_gonk  ON                  (is_foo_gonk.foo_quux_id  =  foo_gonk.foo_quux_id  AND  is_foo_gonk.foo_id  =  foo.foo_id)          UNION                  SELECT  baz.foo_id  FROM  baz  WHERE  baz.value  >  0   )  X  ON  (X.foo_id  =  foo.foo_id)   LEFT  JOIN  foo_has_fliff  zwot  ON  (zwot.foo_id  =  foo.foo_id  AND  zwot.foo_fliff_id  =  246)   INNER  JOIN  foo_quux  bleep  ON  (bleep.label  =  'blort-­‐allow'  AND  bleep.value  =  'thlip')   LEFT  JOIN  foo_quux  bap  ON  (bap.label  =  'blort'  AND  bap.value  =  'ba')   LEFT  JOIN  foo_has_quux  blif  ON  (blif.foo_id  =  foo.foo_id  AND  blif.foo_quux_id  =  bap.foo_quux_id)   LEFT  JOIN  foo_has_quux  fweep  ON  (fweep.foo_id  =  foo.foo_id  AND  fweep.foo_quux_id  =  bleep.foo_quux_id)   WHERE  foo.a  =  1  AND  foo.b  =  0  AND  foo.c  =  0  AND  foo.d  =  0  AND  foo.e  =  0  AND  foo.f  =  0  AND  foo.g  =  1          AND  foo.bar_id  =  12345          AND  zwot.foo_fliff_id  IS  NULL          AND  NOT  (blif.foo_id  IS  NULL  XOR  fweep.foo_id  IS  NULL)   ORDER  BY  foo.tink  DESC  
  • 19. Slow queries Keep an eye on their evolution
  • 20. https://github.com/box/Anemometer   Analyze slow query logs to identify problematic queries Slow queries
  • 22. REALLY slow queries Save your platform, kill them github.com/dailymotion/mysql-­‐genocide   Graph the effects
  • 23.
  • 24. Watching technical debt Information_schema.table_statistics SELECT  t.table_name,  s.rows_read   FROM  information_schema.tables  t   LEFT  JOIN  information_schema.table_statistics  s        ON  (t.table_schema  =  s.table_schema                  and  t.table_name  =  s.table_name)   WHERE          t.table_schema  =  'myschema'          AND  coalesce(rows_read,  0)  =  0   ORDER  BY  1;  
  • 25. Watching technical debt Unused indices SELECT  DISTINCT  t.table_name,  t.index_name,  s.rows_read   FROM  statistics  t   LEFT  JOIN  index_statistics  s          USING  (table_schema,  table_name,  index_name)   WHERE  t.table_schema  =  'myschema'          AND  coalesce(s.rows_read,  0)  =  0   ORDER  BY  1,  2;    
  • 26.
  • 27. Managing change https://github.com/outbrain/propagator   All schema changes are logged (and recorded in git)
  • 28. Managing change (2) Percona Online Schema Change https://www.percona.com/doc/percona-­‐toolkit/2.1/ pt-­‐online-­‐schema-­‐change.html  
  • 29. Future Directions Global Transaction ID (GTID) Parallel replication Multiple source replication
  • 30. Thank you! David Landgren (dland@github, @dlandgren) david@landgren.net Acknowledgements All photos by Gézelin Grée gezelingree.com / 10000lux.blogspot.com   Comic drawn by Randall Munroe / xkcd.com