Running MySQL on AWS Michael Coburn Wednesday, April 15th, 2015
Who am I? 2 Senior Architect with Percona 3 years on Friday! Canadian but I now live in Costa Rica I see 3-10 different customer environments per week, about 50% are now AWS based
Introduction 3 There is a lot of Alphabet Soup in this talk Intention is to de-mystify running MySQL in the cloud using AWS
What is AWS 4 Acronym for Amazon Web Services A division of amazon.com (the book retailer) Operates as a set of connected services EVERYTHING IS A SERVICE! Fun fact: AWS came to be first to support amazon.com until they realised this concept could be monetised
What is Virtualisation? 5 To virtualise: the act of separating the guest OS from the physical server's hardware The guest OS can be Linux, Windows, Solaris, etc Generally we see only Linux deployed in AWS for running MySQL
What is EC2? 6 Acronym for Elastic Cloud Compute The platform most commonly used to run MySQL Traditional virtualisation: you launch and instance of Linux and install MySQL as if it were a regular server Can be provisioned with a range or resources, such as RAM from 1GB to 244GB, and CPU cores from 1 to 32
What is EBS? 7 Stands for Elastic Block Storage Represents a model of virtualising the disk Allows AWS to provision different sizes from 10GB to 1TB and IOPS from 500 to +80,000 Can use multiple EBS volumes along with LVM/mdadm for increasing mount point size and/or RAID redundancy and performance
What is RDS? 8 Stands for Relational Database Service Supports Community MySQL (not Percona Server), Oracle, Microsoft SQL Server, PostgreSQL Automates a lot of the traditional DBA tasks such as: Backups Failover Slave provisioning Allows you to treat your MySQL database as more of a "black box" with the tradeoff that you give up some control
What are IOPS? 9 Stands for Input/Output Operations Per Second Common measurement for disks to rate their throughput The higher the value, the more work your database server can do Work: number of SELECT, INSERT, UPDATE, and DELETE operations is related to amount of IOPS your server has (normally )
Use cases: EC2 10 Control over all facets of MySQL gdb, oprofile, strace, pt-stalk, disk/cpu/ network Generally more mature application Admins want more control or need to tune something that is IsModifiable=false Generally cheaper than RDS
Use cases: RDS 11 Want to treat database like a black box Automated tasks backups, upgrades Easy read-replica setup Easy Multi-AZ failover
Application benefits from AWS? 12 Ease of spinning up new instances On-demand computing resources Pay as you go pricing Flexible pricing models CLI/API access to deploying and configuring resources
Virtualised vs non-virtualised 13 In general there isn t a lot different about running MySQL virtualised vs nonvirtualised You should make specific accommodations for SSD vs magnetic You should pay attention to noisy neighbour conditions
What are the tradeoffs to AWS? 14 Not easy to completely isolate your instance from noisy neighbours Higher latency to disk Overhead from virtualisation layer
Taking backups of MySQL 15 EC2: Percona XtraBackup, mysqldump, LVM or EBS snapshots RDS: mysqldump, RDS snapshots
Changing MySQL configuration 16 EC2: my.cnf, mysql client RDS: Parameter Group + refresh interval, mysql client (more limited)
Upgrading MySQL 17 EC2: yum or apt-get + mysql_upgrade Manual RDS: Maintenance window Automated
Spinning up slaves 18 EC2: take copy of master, stand up slave, start replication at least an hour to hours of effort :) RDS: a few mouse clicks or API calls so like a few seconds?
Failover of MySQL 19 EC2: MHA/PRM, slave promoted to Master RDS: Multi-AZ failover (old Primary goes offline), Read Replicas
Schema changes 20 EC2: pt-online-schema-change, ALTER TABLE RDS: pt-online-schema-change, ALTER TABLE
Monitoring the health of MySQL 21 EC2: Percona Cloud Tools Cacti/Zabbix/etc pt-stalk RDS: Percona Cloud Tools (MySQL Metrics only) Cacti/Zabbix/etc pt-stalk (only somewhat) CloudWatch
Recovering from failure in MySQL 22 EC2: error log innodb_force_recovery Data Recovery RDS: error log automated crash recovery of InnoDB
Things to watch for in AWS 23 Don t leave instances running idle Be careful you don t over-provision instance sizes Take advantage of EBS snapshots Take advantage of multi-az