AWS + MySQL - Percona · Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud...

31
AWS + MySQL Ryan Huddleston Director of Remote DBA Percona Live New York 2012

Transcript of AWS + MySQL - Percona · Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud...

Page 1: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

AWS + MySQL

Ryan HuddlestonDirector of Remote DBA

Percona Live New York 2012

Page 2: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

Agenda● Options for Running MySQL in AWS

● RDS or EC2● IO Performance● Cloud Watch and Percona Monitoring

Plugins● HA Options

Page 3: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

Why AWS● Starting up new nodes is very fast● Only use what is needed and can scale

quickly to meet demand● No upfront capital investment● Can concentrate on writing applications not

on running datacenters, ordering and racking equipment, cable management, redundant network provider contracts

Page 4: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

Amazon RDS or EC2● RDS - Relational Database Service

● Easy to setup without MySQL expertise● Automated Backups● Automated failover during hardware failure● Create read replicas with a few clicks● Ready to connect to mysql over port 3306

● EC2 - Elastic Compute Cloud● More flexible● Can be more cost effective

Page 5: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

Amazon RDS● Cost is 30% higher than EC2 instances● Meant to be a Black Box● High availability using equivalent to DRDB

○ Probably is DRDB underneath○ Recovery time dependent on Innodb Crash

recovery time○ You have to pay 2x the instance cost for HA

and cannot use the other node for queries ○ Backups can use the secondary instance but

beware, it can slow down the master.

Page 6: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

RDS Operation Issues● Migrating out of RDS involves mysqldump and

reload. If your data get's too large the move will be very painful

● No access to binary logs therefore no ability to replicate out of RDS. Also no ability to troubleshoot issues by looking through binary logs (replication logs)

● Binary backups not possible on read replica and snapshots can impact performance. As of 9-26 may be possible to mitigate via provisioned-IOPS option

Page 7: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

RDS Operation Issues - 2● No super_priv, so can't kill queries by other users● Can be difficult for DBA's to troubleshoot● Major upgrades involve dumping and reloading

entire database (e.g. 5.1 to 5.5)● If replication on a read replica breaks, you must

destroy/recreate that instance

Page 8: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

Amazon RDS - cont● You still need DBA's, it doesn't tune your SQL● You may get by with no DBA's if databases is

low to medium usage● If you're having IO or CPU issues, you must rely

on cloud watch metrics to tell you this● As of September 26th you now have provision-

IOPS volumes in RDS to mitigate IO issues○ With RDS you can only buy provisioned IOPS,

1000 per 100 GB which may be too much or little depending on workload

Page 9: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

New node with RDS

Page 10: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

RDS maintenance windows

Page 11: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

Amazon EC2● Very flexible for DBA's that know how to put the

pieces together● Can use Xtrabackup and send to S3 for Backups

○ Options to make it very low impacting (--rsync)○ You must monitor that backups are working

● Upgrading storage or Instance types takes manual work to move data around

● You are in control of IOPS to each volume you can have a 100GB storage with 10,000 IOPS (10x 10GB disk via software RAID 0)

Page 12: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

Amazon EBS

If you RAID-0 more that one EBS volume above you should get EBS optimized instances

Page 13: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

Amazon EC2● You must upgrade MySQL manually, though also

allows for major upgrades with minimal downtime● You must install an HA solution such as Percona

XtraDB Cluster, MMM, MHA, DRDB etc○ You must make sure the secondary master(s)

are up and being monitored properly and is located in a secondary AZ

Page 14: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

Percona Server ● With EC2 You can use alternative forks of

MySQL such as Percona Server that solves real operational issues

○ Drop table locks table cache mutex (innodb_lazy_drop_table)

○ Buffer pool restore at startup (innodb_buffer_pool_restore_at_startup)

○ Speed up ALTER and mysqldump loads (expand_fast_index_creation)

○ cache statistics between restarts (innodb_use_sys_stats_table)

○ innodb_adaptive_flushing_method

Page 15: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

Amazon IO● Amazon historically has had a lot of problems

with database workloads● Databases need consistent IO to work well● Normal EBS (Elastic Block Store) volumes can

do ~100 IOPS○ IO capability fluctuates based on other users

in EBS○ Workarounds included stripping many EBS

volumes together via RAID 0 or even RAID 10

Page 16: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

Amazon IO - cont● In August 2012 AWS announced Provisioned

IOPS EBS volumes● $.10 per month per provision IOPS● $100 per month for 1000 IOPS● Reliable and can allows you to serve a

significant amount of traffic ● Can stripe together volumes via RAID-0 to

go above 1000 IOPS. ○ The same thing RDS is doing under the hood

Page 17: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

Amazon IO Best Practices● Purchase Provisioned-IOPS volumes for MySQL

instances● Start with 1000 IOPS and go from there● Can greatly improve reliability and predictability

of the Database in AWS● In RDS things can get expensive. For example if

you are currently using typically ~200 IOPS but have 800GB of data. Provisioned-IOPS forced you to purchase 8000 IOPS which is $800 per month (twice that for multi-AZ deployments)

Page 18: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

Amazon Best Practices● Use the Ephemeral drive (but not for data)

○ mysql tempdir○ mysql-slow logs especially when

long_query_time=0○ backups, store some local copies, using --

compress on xtrabackup. May be faster than pulling from S3 in a pinch

● Use Xtrabackup for binary backups and send to S3. Also look at Glacier if you need to retain backups for longer periods

Page 19: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

S3 Backups example/usr/bin/innobackupex --compress --rsync /ephemeral_drive/xtrabackup/

NOW=$(date +%y%m%d)

cd /ephemeral_drive/xtrabackup/

LATEST=`ls -1t | head -1`

tar -cf - $LATEST | split -b 500MiB - "/ephemeral_drive/xtrabackup/S3/xtradb_split-$NOW.gz_"

s3cmd --delete-removed --no-check-md5 sync /ephemeral_drive/xtrabackup/S3/ s3://mybucket/mysqldump/

● s3cmd from http://s3tools.org

Page 20: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

Monitoring in AWS

● CloudWatch● Nagios + Percona Monitoring Plugins

Simplicity vs Flexibility

Page 21: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

AWS CloudWatch - RDS● Binlog disk usage● CPU utilization - key metric● DB connections● Free memory● Free disk space● Read and Write IOPS - key metric● Read and Write Throughput● Read and Write Latency● Swap Usage● Replication Lag - only on read replica

Page 22: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

AWS CloudWatch

● Create Alarms● Limited time ranges on Graphs

Page 23: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

Percona Monitoring Plugins● Innodb Deadlocks pt-deadlock-logger + pmp-

check-mysql-deadlocks● Threads Running:

○ pmp-check-mysql-status -x Threads_running -w 40 -c 80

● Processes in bad states:○ pmp-check-mysql-processlist

● Long Running Transactions that haven't committed, pmp-check-mysql-innodb

● Status of Percona XtraDB Cluster:○ pmp-check-mysql-status_pxc

Page 24: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

Percona Monitoring Plugins + Nagios

● Replication Running● Replication Lag:

○ pmp-check-mysql-replication-delay plus pt-heartbeat

● Free Memory● Disk space● Anything you can think of

● Investigating integrating CloudWatch into Nagios via AWS API's

Page 25: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

Percona Monitoring Plugins + Nagios

Page 26: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

Other Monitoring Tools● pt-stalk

○ RainGauge ○ https://github.com/box/RainGauge

● Box/Anemometer○ https://github.com/box/Anemometer

Page 27: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

High availability● PXC - Percona XtraDB Cluster

○ Plans to test configurations having nodes split between different AZ's

● MHA/MMM○ one monitoring node

● Corosync/Pacemaker○ Investigating better ways to integrate with tools like

MHA○ must use unicast in AWS○ Can't do vip failover○ Investigating using similar methods to PXC + HaProxy

Page 28: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

Conclusions● AWS is better able to handle database workloads now

with provisioned IOPS● EC2 is more cost effective and flexible if you know what

you're doing● RDS is great for low-medium sized databases where

there are no dedicated DBAs● Combination and CloudWatch and Nagios/Percona

Monitoring Plugins may work well in Amazon● Amazon's multiple availability zones is a nice feature.

Run your HA across without the traditional problems with remote data centers for DR○ Percona XtraDB Cluster may be a good option here

Page 29: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

Questions?

Page 30: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

Percona LiveLondon

Visit:http://www.percona.com/live/london-2012/

London UK,Dec 4-5

Registration is Open!

Page 31: AWS + MySQL - Percona ·  Agenda Options for Running MySQL in AWS RDS or EC2 IO Performance Cloud Watch and Percona Monitoring Plugins HA Options

www.percona.com

Annual Percona LiveMySQL Conference and Expo

The Hyatt Regency Hotel, Santa Clara, CA

April 22nd-25th, 2013 Registration

and Call for Papers

are Open! Visit:

http://www.percona.com/live/mysql-conference-2013/