Atmosphere 2014: Scaling MySQL in 2014? - Przemyslaw Malkowski
Upcoming SlideShare
Loading in...5

Atmosphere 2014: Scaling MySQL in 2014? - Przemyslaw Malkowski



MySQL was the first database system developed particularly with web applications use in mind. But it made a long way since 1995. How is it keeping up with today's internet demands? ...

MySQL was the first database system developed particularly with web applications use in mind. But it made a long way since 1995. How is it keeping up with today's internet demands?
How to scale the most popular database for the web these days? What are the best practices to scale MySQL and keep it fast, without headaches? Are there any good examples of large scale use cases?
In this talk I will try to answer to those questions. I will try to focus on new features in recent MySQL versions, but also to present an open source, fast growing clustering solution making MySQL for the cloud really easy and flexible.

Przemyslaw Malkowski - Przemek's job is to help using MySQL optimally in many various scenarios. He works in Support Team at Percona since 2012. Before that he spent over five years working for (Quantcast Top 50) as System Administrator where he was a key person responsible for seamless building up MySQL powered database infrastructure. Besides MySQL he worked on maintaining all other parts of LAMP stack, with main focus on automation, monitoring and backups.



Total Views
Views on SlideShare
Embed Views



0 Embeds 0

No embeds


Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

Atmosphere 2014: Scaling MySQL in 2014? - Przemyslaw Malkowski Atmosphere 2014: Scaling MySQL in 2014? - Przemyslaw Malkowski Presentation Transcript

  • Scaling MySQL in 2014? Przemysław Malkowski Atmosphere 2014
  • What is this talk about? ● Is MySQL still a good choice for today's web projects? ● Does it work on scale? ● Does it work in cloud? ● How MySQL is evolving to keep up with changes? ● What are the best practices to scale? ● Improved replication and clustering
  • Still right choice? ● MySQL first released in 1995 ● Open Source/GPL (3.23) since 2000/2001 ● Owner changes – MySQL AB, Sun, Oracle ● Competition – Percona, MariaDB ● NoSQL movement ● Cloud boom View slide
  • Most popular database for web ● 'M' in LAMP ● Default database for webhosting offers ● Most popular CMS/blog/forum software supports mainly MySQL ● Top world biggest web sites use MySQL ● OpenStack: default DBaaS provider View slide
  • Can you scale with MySQL? ● Do you plan to reach the scale of Facebook? ● From Harrison Fisk talk in 2013: – many petabytes of data (real time access) – 11M row changes /s – 60M selects /s – 2.5B rows read /s ● WebScaleSQL ● Not IF but HOW
  • Scaling for the web ● Stay fast and reliable as you grow ● More visitors/users ● More features/products ● Continuous performance optimization ● How fast you can serve client request? ● You may not know how bad your application or configuration is until...
  • Best practices ● Design your schema well ● Primary key in each table! ● Secondary keys designed with application ● Do the fancy stuff asynchronously! ● Advanced reports, statistics? ● Remember the OLTP principles
  • Best practices ● Cache ● Use the right tools! ● Percona XtraBackup ● Percona Toolkit ~ 30 tools including pt-online-schema-change, pt-query- digest, pt-table-checksum, and more ● Percona Monitoring Plugins – Nagios, Cacti, Zabbix
  • Do my queries scale? ● Percona Cloud Tools
  • Scalability areas
  • Not quite that simple ● Number of connections ● Total active ● New connections per second ● Write conflicts (deadlocks) ● Stale data ● Large data management ● Backups ● Node provisioning ● Number of databases and tables
  • Scale up
  • Scale up ● More/faster CPU cores ● More memory ● Bigger disks ● Faster disks ● Application optimization/redesign ● MySQL optimization! ● Default is not good
  • Scale up – MySQL version matters!
  • Scale up – use the right engine ● Forget MyISAM!
  • Scale up – use right engine ● InnoDB - business standard ● Hot backups (MEB, Percona XtraBackup) ● Online schema change (pt-osc or in 5.6+) ● Compression (Facebook++) ● TokuDB ● Excellent compression ● Impressive write throughput ● Will be shipped with Percona Server 5.6 soon (beta builds available)
  • Data growth ● How fast can you make a full backup? No! How fast can you restore from backup! ● How fast can you provision number of nodes capable of handling the traffic (worst case scenario)? ● How fast can you alter table ● Query performance (fit hot data in memory)
  • Scale out
  • Scaling out - replication ● Cons ● Complexity – application and DBA ● Data consistency issues ● Slave lag ● Writes are a bottleneck writes reads replication master slaves MySQL replication (async) ● Pros ● Easy to deploy ● Flexible replication topology ● Unlimited slaves ● No write latency on master
  • Scaling out – MySQL replication ● Replication improvements: ● GTID (5.6, MariaDB 10) ● Semi-sync replication (5.5+) ● Multi-threaded slaves per-database (5.6+) ● Multi-threaded slaves intra-database (5.7) ● Multi-Source replication (MySQL 5.7, Maria 5.5) ● Still master -> slave(s)
  • Make it simple ● Does complexity scale? ;) ● Team experience ● How fast can you make changes? ● Humans make errors ● Demand for HA increases as you grow ● Simpler management -> higher availability
  • Scaling out made easy – Percona XtraDB Cluster ● Complete HA solution: ● Percona Server (5.5 or 5.6) ● Galera library from Codership ● Percona XtraBackup ● Core features ● Synchronous replication ● Multi-master replication ● Parallel replication ● Automatic node provisioning ● No need for application change - keep using InnoDB
  • PXC – how does it work GALERA REPLICATION node1 node2 node3 Reads Writes Reads Writes Reads Writes ● No SPOF - availability ● Data consistency ● No partitioning tolerance ● Reasonable overhead ● Transactions pass certification test before returning to the client but applying is done asynchronously ● Row based, parallel replication ● No slave lag
  • PXC - Data consistency is priority Node partitioned from the cluster
  • PXC - Syncing nodes ● Incremental State Transfer (IST) ● Gcache (Writeset Cache) ● State Snapshot Transfer (SST) ● Adding a new node ● Rebuilding failed node ● Node's consistency was compromised
  • GALERA REPLICATION PXC - Automatic node provisioning Fast and non-blocking with Percona XtraBackup node1 node2 JOINER node4 DONOR node3 SST
  • GALERA PXC – replication flexibility Async master Async slave GTID
  • PXC – WAN awareness ● WAN segments (Galera 3+) DC1 DC2 DC3 DC3 DC2 DC1 ● Smart donor selection ● Less network traffic
  • Scaling out (writes) ● Functional Partitioning ● Sharding Cluster A Cluster B ID 1-1000 ID 1001-2000
  • Sharding/partitioning – solutions ● Make your application shard aware (design your own logic) ● Use existing solutions ● MySQL Fabric ● Shard-Query
  • Cloud ● Scaling on demand, unlimited ● “MySQLaaS” ● Amazon RDS ● Google Cloud SQL (MySQL only) ● Rackspace Cloud Databases (MySQL only) ● HP Cloud Relational Database (MySQL only)
  • References Benchmarks Large scale New cool stuff Cloud Sharding PXC use cases
  • Learn from MySQL Community
  • We're Hiring!