Running MySQL on AWS Michael Coburn Wednesday, April 15th, 2015
Running MySQL on AWS
Michael Coburn Wednesday, April 15th, 2015
Who am I?
• 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
2
Introduction
• There is a lot of Alphabet Soup in this talk • Intention is to de-mystify running MySQL
in the “cloud” using AWS
3
What is AWS
• 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
4
What is Virtualisation?
• 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
5
What is EC2?
• 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
6
What is EBS?
• 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
7
What is RDS?
• 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
8
What are IOPS?
• 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…)
9
Use cases: EC2
• 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
10
Use cases: RDS
• Want to treat database like a “black box” • Automated tasks • backups, upgrades
• Easy read-replica setup • Easy Multi-AZ failover
11
Application benefits from AWS?
• 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
12
Virtualised vs non-virtualised
• In general there isn’t a lot different about running MySQL virtualised vs non-virtualised
• You should make specific accommodations for SSD vs magnetic
• You should pay attention to “noisy neighbour” conditions
13
What are the tradeoffs to AWS?
• Not easy to completely isolate your instance from “noisy neighbours”
• Higher latency to disk • Overhead from virtualisation layer
14
Taking backups of MySQL
• EC2: Percona XtraBackup, mysqldump, LVM or EBS snapshots
• RDS: mysqldump, RDS snapshots
15
Changing MySQL configuration
• EC2: my.cnf, mysql client • RDS: Parameter Group + refresh interval,
mysql client (more limited)
16
Upgrading MySQL
• EC2: yum or apt-get + mysql_upgrade • Manual
• RDS: Maintenance window • Automated
17
Spinning up slaves
• 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?
18
Failover of MySQL
• EC2: MHA/PRM, slave promoted to Master • RDS: Multi-AZ failover (old Primary goes
offline), Read Replicas
19
Schema changes
• EC2: pt-online-schema-change, ALTER TABLE
• RDS: pt-online-schema-change, ALTER TABLE
20
Monitoring the health of MySQL
• EC2: • Percona Cloud Tools • Cacti/Zabbix/etc • pt-stalk
• RDS: • Percona Cloud Tools (MySQL Metrics only) • Cacti/Zabbix/etc • pt-stalk (only somewhat) • CloudWatch
21
Recovering from failure in MySQL
• EC2: • error log • innodb_force_recovery • Data Recovery
• RDS: • error log • automated crash recovery of InnoDB
22
Things to watch for in AWS
• 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
23