How to take advantage of Amazon Aurora Autoscaling for WordPress
The task of deploying CMS in cloud systems is now becoming the de facto standard for many applications. Because CMS WordPress serves a huge proportion of websites on the Internet, users are thinking about saving resources and budget and increasing system resiliency.
There are many ways to solve the scaling problem in cloud systems that work well with CMS. One of the common options is to use Amazon Aurora.
Let's take a step-by-step look at how this works.
WordPress is an open-source site content management system that is written in PHP and uses a MySQL database server. WordPress is released under the GNU GPL version 2 license. The scope of this system ranges from blogs to quite complex news resources. The built-in system of "themes" and "plug-ins" together with successful architecture allows the user to design projects of wide functional complexity.
WordPress needs very little to work:
- PHP version 5.6 or higher;
- MySQL version 5.0 or higher;
- the Apache mod_rewrite module (for addresses called persistent links).
According to various sources and the W3Techs laboratory, in 2015 25% of all sites operated under WordPress, in 2018 - more than 30%, and in March 2020 - more than 36% (market share of content management systems is 63%).
Amazon Aurora is a cloud-based, MySQL- and PostgreSQL-compatible relational database that combines the speed and availability of traditional commercial databases with the simplicity and cost-effectiveness of open source databases.
Amazon Aurora runs five times faster than standard MySQL databases and three times faster than standard PostgreSQL databases. It provides security, availability, and reliability at the level of commercial databases at a cost 10 times less. Amazon Aurora is fully managed by the Amazon Relational Database Service (RDS), which automates time-consuming administration tasks such as hardware allocation, database configuration, patch installation, and backup.
Amazon Aurora uses a failover, self-healing, a distributed storage system that automatically scales to 64 TB per database instance. Aurora delivers high performance and availability with up to 15 low-latency replicas, instant recovery, continuous backup to Amazon S3, and replication in three availability zones.
To configure Amazon Aurora, you need to go to the Amazon RDS management console to create your first instance of the Aurora database and start migrating the MySQL and PostgreSQL databases.
Let’s take a look of benefits of Amazon Aurora:
High performance and scalability
The database runs five times faster than a standard MySQL database and three times faster than a standard PostgreSQL database. Productivity corresponds to the level of commercial databases, and the cost is about ten times less. As needs change, you can easily scale the database deployment in the right direction by using different types of instances. When using Aurora Serverless, scaling can be done automatically. You can add up to 15 low-latency replicas in three availability zones to scale resources and read performance. If necessary, Amazon Aurora automatically increases the storage capacity up to 64 TB per database instance.
High availability and reliability
Amazon Aurora provides more than 99.99% availability with support for six copies of data in three availability zones and continuous backup of your data to Amazon S3 storage. Recovery from physical storage failures goes unnoticed by the user, and instance failure typically takes less than 30 seconds to process. The service also allows you to return to the specified point in the past in a few seconds to correct user errors. The global database means that one Aurora database covers several AWS regions. This allows for high-speed local reading and fast disaster recovery.
High level of security
Amazon Aurora provides several levels of database protection. These include network isolation using Amazon VPC, data encryption at rest using keys that you create and control in the AWS Key Management Service (KMS), and encryption of transmitted data using SSL. The Amazon Aurora encrypted instance encrypts basic storage data, as well as automatic backups, snapshots, and replicas in the same cluster.
Compatible with MySQL and PostgreSQL
The core of the Amazon Aurora database is fully compatible with existing MySQL and PostgreSQL open source databases. This means that MySQL or PostgreSQL databases can simply be migrated to Aurora using standard MySQL or PostgreSQL import/export tools or status snapshots. This also means that most of the code, applications, drivers, and tools that already work with existing databases can be used with Amazon Aurora without modification or with minor modifications.
Amazon Aurora is fully managed by the Amazon Relational Database Service (RDS). Aurora automatically and continuously monitors the database and backs up the Amazon S3, ensuring accurate recovery at a given point in time.
Compatibility with MySQL and PostgreSQL makes Amazon Aurora attractive as a target database when migrating databases to the cloud. To migrate commercial databases, you can use the AWS Database Migration Service, which provides secure migration with minimal downtime.
To meet connection and workload requirements, Aurora Auto Scaling dynamically adjusts the number of Aurora replicas provided for the Aurora DB cluster using single-master replication. Aurora Automatic scaling is available for both Aurora MySQL and Aurora PostgreSQL. Aurora automatic scaling allows the Aurora DB cluster to cope with a sudden increase in the number of connections or workload. When the connection or workload decreases, Aurora Auto Scaling removes unnecessary Aurora replicas so that you do not pay for unused prepared instances of the database.
The client can define and apply a scaling policy to the Aurora DB cluster. The scaling policy specifies the minimum and maximum number of Aurora replicas that Aurora Auto Scaling can manage. In accordance with this policy, Aurora Auto Scaling adjusts the number of Aurora replicas based on the actual workload based on the actual workloads determined by Amazon CloudWatch metrics and target values.
You can use the AWS Management Console to apply a scaling policy based on a predefined metric. Alternatively, you can use the AWS or Aurora Auto Scaling API command-line interface to apply a scaling policy based on a predefined or custom metric.
As mentioned on Amazon web site, “Database maintenance for your WordPress site is critical. Your database instance holds all of your important data for your WordPress site. If the database goes down, your website may go down with it, and you could even lose your data.
Database maintenance can also be difficult, and database administrators have years of specialized experience. When setting up a WordPress site, you want to stay focused on designing your page and generating your content, not worrying about database performance and backups. Amazon RDS for MySQL helps with both of these problems. Amazon RDS for MySQL is a managed database offering from AWS.”
To install WordPress on Amazon Aurora the following steps need to be done:
- Use Amazon EC2 instance to install and host the WordPress application.
- Use Amazon RDS for MySQL database to store your WordPress data.
- Create an EC2 instance
- Configure your RDS database
- Configure WordPress on EC2
- Explore your new web site and clean up
Then with Amazon Aurora, you will have:
- Automated backup and recovery so that you won’t lose data in the event of an accident;
- Regular updates and patches, keeping your database secure and at peak performance
- Easy installation with smart default parameters.
Also, HyperDB is a replacement (wrapper) for the WPDB class that helps to separate read and write traffic and direct them to different connections. From our experience, this made it possible to use the Aurora Writer instance (for read/write) and the Reader endpoint from WP. Once the Reader endpoint was getting traffic, that made it possible to take advantage of the Autoscaling.
The main advantages of HyperDB are:
- HyperDB can be connected to an arbitrary number of database servers,
- HyperDB inspects each query to determine the appropriate database.
In conclusion, let’s note that the use of cloud systems in the CMS brings real benefits when working with content. It saves budget, a single system administrator can service more CMS, and significantly fewer problems appear with system failures and data recovery.
Because cloud systems scale well, we don't need to keep Amazon instances to work with a large number of users. As soon as the load on the system drops, we can immediately reduce the number of resources consumed in the cloud.
Since Amazon Aurora allows you to use the regions, the content can be delivered to each consumer much faster, depending on its connection.
Our specialists from Luneba are very well versed in cloud systems and will be happy to set up a CMS for you in the cloud. We can work with both Amazon and other cloud systems.