More Related Content Similar to DAT203_Running MySQL Databases on AWS (20) More from Amazon Web Services (20) DAT203_Running MySQL Databases on AWS1. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Running MySQL Databases
on AWS
D A T 2 0 3
N o v e m b e r 2 8 , 2 0 1 7
AWS re:INVENT
Sailesh Krishnamurthy
S e n i o r S o f t w a r e D e v e l o p m e n t M a n a g e r , A m a z o n A u r o r a
2. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Agenda
• Choosing your AWS Deployment Strategy for MySQL
• Running MySQL in Amazon EC2
• Using Managed MySQL in AWS
• Amazon RDS for MySQL
• Amazon RDS for MariaDB
• Amazon Aurora
• Tips for Managed MySQL Databases in AWS
• Multi-AZ Configurations
• Read Replicas
• Monitoring
3. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
A Brief History of MySQL
• World’s most commonly used relational database
• Key component of the LAMP open source web application software stack
• Used in open source applications such as WordPress, Joomla, Redmine, and Drupal
• History
• First released in 1995 in Sweden by MySQL AB
• Acquired by Sun in 2008
• Launched as first Amazon RDS engine in 2009
• Acquired by Oracle in 2010
• Popular Branches
• MySQL Community Edition
• MySQL Enterprise Edition
• MariaDB Server
• Percona Server
• Amazon Aurora MySQL
Amazon RDS
4. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Choosing your AWS MySQL Deployment
Strategy
Amazon EC2 Amazon RDS
Self-managed
on application
server
Self-managed
on database
server
AWS-managed
open source
engines
AWS-managed
cloud native
engine
Control Automation
5. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• Full control over parameters of server, OS,
and database
• Remote access to host via remote shell
• Customer can install 3rd party applications
and extensions
• Customer has full responsibility for
upgrades and backups
• Customer has full responsibility for security
• High Availability, Disaster Recovery and
read scaling are expensive, complex, require
a lot of engineering
• Database is a managed appliance, so
customers can easily automate, clone and
scale
• No host access—all configurations through
AWS APIs
• Limited to managed extensions and tools
• OS and DB upgrades, data backup and
restore are provided as a service
• High infrastructure security, encryption,
certifications, tools to ensure DB security
• High Availability, Disaster Recovery, and
read scaling are managed service with a
button click or API call
A W S - m a n a g e d d a t a b a s eS e l f - m a n a g e d d a t a b a s e
Self-managed vs. AWS-managed Databases
6. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Running MySQL in Amazon EC2
• Install
• Install a MySQL distribution via yum or choose a pre-built machine image from the
AWS Marketplace
• Consider using EBS volumes vs. ephemeral disks
• Configure
• Operating System Configuration
• Networking and Security Configuration
• Backup/restore
• mysqldump, MySQL Enterprise Backup, Percona XtraBackup
• Cluster/replicate
• Semi-synchronous replication
• Galera Cluster/MySQL Cluster/Percona Cluster
• Monitor
• Leverage AWS CloudWatch for OS metrics
• MySQL Monitoring tools—DataDog, Percona, VividCortex, WebYog
7. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Benefits of Running Managed MySQL
• Managed high availability through automated
failover across multiple data centers
• Managed disaster recovery with to the minute
point-in-time recovery
• Managed read scaling through read replicas
• Push button provisioning, automated instance
and storage scaling, patching, upgrades,
security, and general care and feeding
• Lower TCO because we manage the muck
• Get more leverage from your teams
• Focus on the things that differentiate you
8. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
“Amazon RDS allowed us to focus
a little less on MySQL
administration and a little more
scaling out the rest of our service."
- Joey Parsons
Head of Operations at Flipboard
”
“
Flipboard is one of the world's first social magazines. Inspired
by the beauty and ease of print media, the company’s mission
is to fundamentally improve how people discover, view, and
share content across their social networks.
• From the beginning, Flipboard has
run its infrastructure on Amazon Web
Services
• One key decision was to use MySQL,
and in turn, Amazon RDS
• Flipboard uses Amazon RDS for
MySQL and its Multi-AZ capabilities
to store mission critical user data
• Key features are auto minor version
upgrade, automatic backups, easy
restores, and the ability to spin up
read replicas to add capacity
Customer Story: Flipboard
9. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Managed MySQL Compatible Engines
in AWS
Standard
The open source
standard MySQL
Community
The popular
community choice
Amazon Aurora
Performance
The fastest MySQL
compatible engine
10. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon RDS for MySQL
• Support for MySQL Community Edition versions 5.5, 5.6 and 5.7
• InnoDB and MyISAM storage engines
• Version 5.7—new features
• JSON support
• Query optimizer improvements
• GIS extensions
• Improved parallel replication
• Dynamic buffer pool resizing
• Version 8.0 coming soon
11. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon RDS for MariaDB
• Support for versions 10.0 and 10.1
• Same instance, regions, pricing as RDS for MySQL (including free tier)
• Differences from RDS MySQL
• XtraDB and Aria storage engines only
• Thread Pooling
• GTID
• Version 10.1—new features
• XtraDB page compression, data scrubbing, and defragmentation
• Optimistic in-order parallel replication
• ORDER BY optimization
• Version 10.2 coming soon
12. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Aurora
• Built from the ground up to leverage AWS
• MySQL 5.6 compatible with up to 5x better
performance on the same hardware:
100,000 writes/sec and 500,000 reads/sec
• Scalable with up to 64 TB in single database, up
to 15 read replicas
• Highly available, durable, and fault-tolerant
custom SSD storage layer: 6-way replicated
across 3 Availability Zones
• Transparent encryption for data at rest using
AWS KMS
• Stored procedures in Amazon Aurora can invoke
AWS Lambda functions
13. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Best Practices for MySQL Engines
14. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Migrating your MySQL Database into AWS
• Data Import Options
• Use mysqldump and mysql command line
• Use mysqlimport on EC2 instance
• Use external replication into AWS for minimizing downtime
• Use AWS Database Migration Services
(heterogeneous migrations/database consolidation)
• Import Backup from Amazon S3
• New for RDS MySQL
• Create full or incremental backup
with Percona XtraBackup 2.3
• Use AWS IAM role to access S3 bucket
• Use replication to catch up to changes in the
source database (if necessary)
15. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Configuring your MySQL instance
for data loading
• Turn off backup retention (disables binlog)
• Turn off autocommit mode
• Drop indexes and disable foreign keys
• For EBS-based engines
• Use EBS-optimized instance types
• Maximize storage IOPS
• Optimize parameter settings
• innodb_flush_log_at_trx_commit, innodb_io_capacity,
innodb_io_read_threads, innodb_io_write_threads, sync_binlog
• Remember to re-enable settings after load completes!
16. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
MySQL/MariaDB Engines Best Practices
• Leverage Multi-AZ Configurations
• High availability for planned and unplanned
events
• Leverage Read Replicas
• Read scalability, disaster recovery, upgrades
• Leverage Enhanced Monitoring
• Additional information for tuning and
troubleshooting
• CloudWatch Logs charge (small)
17. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Multi-AZ High Availability
• An Availability Zone is a physically distinct, independent infrastructure
• Your database is synchronously replicated to another AZ in the same AWS region
• Failover occurs automatically in response to the most important failure scenarios
18. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Managed MySQL Engines Multi-AZ Tips
• MySQL and MariaDB
• Configure Multi-AZ before you go into production
• Multi-AZ failovers can be less than a minute with most of the downtime in DNS
propagation
• Multi-AZ introduces an extra commit latency so MAZ IOPS will typically be lower
compared to SAZ
• If MySQL needs to do a crash recovery or other I/O intensive operation before it can
start, the speed of storage will have significant impact on startup time
• Amazon Aurora
• Amazon Aurora automatically replicates your storage six ways, across three
Availability Zones
• Use Multi-AZ instance for additional availability
• Failovers are typically under 30 seconds
• Assign a promotion priority tier to each instance on your database cluster to get more
control over replica promotion during failovers
19. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Horizontal Scaling with Read Replicas
• Horizontal scaling of read heavy workloads
• Offload long reporting queries
• Easy to re-create if fallen behind
• Cross-Region Read Replicas bring data close to your applications in different regions
• Promote read replica to a master for faster recovery in the event of disaster
• Amazon Aurora uses shared storage within a region so no additional storage
20. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon RDS for MySQL/MariaDB
Replication Tips
• Read Replicas can be made writeable
• Useful for changes like adding an index for reporting
• Think of it as “breaking the warranty”
• Amazon RDS supports managed replication chaining (source > target > target)
• Replica in one region and then a cross-region replica in another region
• Amazon RDS limits to 5 replicas per source (can be extended upon request)
• Amazon RDS instances support non-managed replication
• Uses stored procedures rather than RDS API
• Useful for on-premises to RDS, EC2 to RDS scenarios
• Safety Tips
• MariaDB provides crash-safe replication using Global Transaction Identifiers (GTIDs)
• Always have a primary key on a replicated table!
• Leave sync_binlog set to 1 (RDS default)
21. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Aurora Replication Tips
• Use Aurora Replicas for scaling read operations and increasing availability
• Aurora Replicas are independent endpoints in an Aurora DB cluster
• Low latency, no additional database storage
• Up to 15 Aurora Replicas can be distributed across the Availability Zones
that a DB cluster spans within an AWS Region
• Use reader endpoints for load balancing
• New—use auto-scaling of Replicas in the reader endpoint
• Use logical (binlog) replication for cross-region or external sources and targets
• Can use Amazon Aurora as replica of your MySQL Database
• If you do use multi-threaded replication, we recommend that you test
thoroughly
22. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• Amazon CloudWatch metrics visible in the
AWS Console
• CPU utilization
• Storage
• Memory
• I/O (read and write)
• Latency (read and write)
• Throughput (read and write)
• Replica lag
• Many additional metrics for Amazon
Aurora
• More coming soon!
• Amazon CloudWatch Alarms
• Integrated with third-party monitoring
tools
Amazon RDS CloudWatch Metrics
23. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• Additional 50+ system/OS
metrics in the AWS
Console
• Sorted process list view
• 1-60 sec granularity
• Alarms on specific metrics
• Egress to CloudWatch Logs
• Integration with
third-party tools
Amazon RDS Enhanced Monitoring
24. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• Measures “DB Load,” aka Average
Active Sessions
• Identifies source of bottlenecks
• Easy
• Powerful
• Top SQL
• Enables problem discovery
• Adjustable timeframe
• Hour, day, week, and longer
• Coming soon for Amazon Aurora
MySQL, Amazon RDS for MySQL,
and Amazon RDS for MariaDB
Amazon RDS Performance Insights
25. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Audit Plug-in for MySQL Engines
• Provides customer configurable event logging for database activity
• Auditable events include logins, queries, and tables accessed
• Individual users can be included or excluded from the audit
• The MariaDB audit plug-in is supported on the following RDS engines:
• MySQL 5.6
• MySQL 5.7
• MariaDB 10.0
• MariaDB 10.1
• Amazon Aurora
• Available via RDS option group
• Be sure to test for impact on server performance
26. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Thank you!
a w s . a m a z o n . c o m / r d s