Amazon RDS makes it easy to set up, operate, and scale, relational databases in the cloud. Amazon RDS for MySQL supports applications that require up to tens of thousands of IOPS, and allows you to scale on demand without administrative complexity.
In this webinar, we will discuss best practices for getting the most out of Amazon RDS for MySQL, as well as techniques for migrating data to and from the service.
6. Things to consider – Read Replicas
• MySQL replication is single-threaded
• MySQL 5.1 and 5.5 – Replication may stop after crash
recovery on the master
– sync_binlog = 0 by default
– Includes Multi-AZ failover
– mysql.rds_next_master_log if potential missing info. is acceptable.
• MySQL 5.6 – Crash safe slaves
– sync_binlog = 1 by default
– Less performance impact but more replica reliability
21. Read/Write Benchmark – Using RR
130GB Data - Partial Random 90R/10W Workload – 10K IOPS
120,000
100,000
TPS
80,000
126,000
60,000
40,000
42,000
20,000
5,850
47,000
db.m2.4xlarge
db.cr1.8xlarge
13,200
-
db.m1.large
db.m1.xlarge
cr1 + 3 x 4xlarge
22. Things to consider – Provisioned IOPS
• Use Provisioned IOPS optimized instances
– M1.L, M3.XL, M2.2XL (500Mbps)
– M1.XL, M3.2XL, M2.4XL (1000Mbps)
– CR1.8XL (>1000 Mbps)
• Understand Channel Bandwidth
– Full duplex
– 1000 Mbps ~ 100MBps (with protocol overhead) or
– 100 MBps ~ 6250 16KB IOPS
23. Things to consider – Provisioned IOPS
• Max realizable IOPS
– Workload dependent
– 1:1 R/W -> Max realizable IOPS ~12.5K 16KB IOPS for M2.4XL
– 1:1 R/W -> 20K 16KB IOPS for CR1.8XL
• Provisioning more than Max can help lower latency
• IO Size
– IO Sizes <= 16KB is same
– IO Sizes > 16KB consumes more IO
– 6250 16KB IOPS = 3125 32KB IOPS
24. Things to consider – Provisioned IOPS
• Not able to realize IOPS provisioned?
–
–
–
–
Using Provisioned IOPS optimized instances?
Running automated backups, snapshots, scale storage?
Reviewed Queue Depth?
Database contention? Locking? Deadlocks?
25. Other Best Practices
• Storage Engine
– Avoid MyISAM – not transactional
• Cloudwatch alarms
– CPU, Memory, Storage, Latency, Replica Lag
• SMS/email notifications
– Failover, Replication status
• Number of Tables
– Not more than 1000 tables (standard) and 10,000 tables (PIOPS)
27. RDS Pre-Migration Steps
•
•
•
•
•
Stop applications accessing the DB
Take a snapshot
Disable backups
Use Single-AZ instances
Configure security for cross-DB traffic
28. Importing from a MySQL DB Instance
Application
DB
Application
mysqldump
Staging
area
Load data
scp
Tsunami UDP
Staging server
Replication
AWS Region
29. Create a DB Instance for MySQL and EC2
Create DB instance for MySQL using AWS Management Console or CLI
PROMPT>rds-create-db-instance mydbinstance -s 1024 -c db.m3.2xlarge -e MySQL - u
<masterawsuser> -p <secretpassword> --backup-retention-period 3
Create Amazon EC2 (Staging server) using AWS Management Console or CLI
aws ec2 run-instances --image-id ami-xxxxxxxx --count 1 --instance-type m3.2xlarge --key-name
MyKeyPair --security-groups MySecurityGroup
Create replication user on the master
mysql> GRANT SELECT,REPLICATION USER,REPLICATION CLIENT ON *.* TO
repluser@‘<RDS Endpoint>' IDENTIFIED BY ‘<password>';
30. Configure the Master Database
Record the “File” and the “Position” values.
$ mysql -h localhost -u root -p
mysql> show master statusG
*************************** 1. row ***************************
File: mysql-bin.000023
Position: 107
Binlog_Do_DB: mytest
Binlog_Ignore_DB:
1 row in set (0.00 sec)
32. Upload Files to Amazon EC2 using UDP
• Tar and compress MySQL dump file preparation to
ship to Amazon EC2 staging server.
• Update the Amazon EC2 security group to allow
UDP connection from the server where the dump file
is being created to your new MySQL client server.
• On the Amazon EC2 staging instance, untar the
tar.tgz file.
33. Configure the Amazon RDS database
Create the database
mysql> create database bench;
Import the database that you previously exported from the master database
Mysql> load data local infile '/reinvent/tables/customer_address.txt' into table customer_address
fields terminated by ',';
Mysql> load data local infile '/reinvent/tables/customer.txt' into table customer fields terminated by ',';
Configure the slave DB instance for MySQL, and start the slave server
mysql> call mysql.rds_set_external_master(‘<master
server>',3306,‘<replicationuser>',‘<password>','mysql-bin.000013',107,0);
mysql> call mysql.rds_start_replication;
34. Make Amazon RDS instance the Master
Switch over to the RDS instance
– Stop the service/application that is pointing at the Master
Database
– Once all changes have been applied to New RDS
Database. Stop replication with “call mysql.rds_stop_replication”
– Point the service/application at the New RDS Database.
– Once Migration is complete. “call mysql.
rds_reset_external_master”
35. RDS Post-migration Steps
•
•
•
•
•
Turn on backups
Turn on multi-az
Tighten down security
Set up alarms for key metrics
Turn on notifications for Database Events
36. References
• Data Import Guide for MySQL
• Best practices/operational guidelines
• Using Amazon RDS Notifications