December 6, 2018 / Nirav Shah
Migrate your WordPress site on AWS and get benefit of cloudfront and other services.
EXTRACT We are going to share the steps that can be performed to migrate/host WordPress on AWS Services using EC2, S3 and Cloudfront services and to connect these services which will result in the website becoming more responsive and speedy than on any other cloud hosting.
WordPress is one of the most popular open source software, which is probably the easiest and powerful blogging and website content management system (CMS) in existence today. It’s popularity is well known as it powers more than 30% website of the internet.
So, How do you make a powerful blogging and website CMS more powerful, efficient and ultra-responsive???…Simple, by hosting it on Amazon Web Services(AWS).
AWS is a leading cloud service provider in the market and provides a vast variety of services almost fulfilling every user’s specific requirements with exceptionally low down times and overall good user reviews.
To bring out the full potential of WordPress and AWS, you need to design a proper AWS architecture for the site to remain speedy, secure and simple.
The most basic and general server architecture which we can implement is
In the above diagram; every service is being used for a reason and has been assigned a particular role to provide viewers with content as speedy and responsive as possible
Route-53
Cloudfront
S3
EC2
RDS
VPC
WordPress Plugins
Explanation
In the above diagram following processes are taking place for the viewer to view your site content.
The viewer sends a request to Route-53 DNS service by entering your domain name in the browser.
Route-53 service routes the request to CloudFront CDN service.
All the requests are bifurcated into 2 different types : (1) image content request and (2) other content request{.css;.js;.html; etc.}. The (1)image content request is served by CloudFront and (2)other content request is routed to the main website EC2 server.
The CloudFront Service checks whether the image content requests being sent are cached within itself or not; if the requested content is cached, then CloudFront responds to viewer request by serving the cached content.
But, before serving any image content request, CloudFront sends a “if-Modified-Since” header request to origin website EC2 server and only on receiving “HTTP status code 304 – Not modified” reply, it will serve the cached content.
But, If the origin website server does not send a “HTTP status code 304 – Not Modified” reply, then the viewer request is forwarded to origin website server which uploads the new image content in S3 bucket and the new updated image content is served to the viewer; at the same time that updated image content is cached by CloudFront to serve next time it receives a request for that particular Image content. You can configure CloudFront to continuously keep on checking for updated content from the origin website server by Setting the “Cached Content TTL” to “0 seconds” in the CloudFront configuration page so that CloudFront can serve even dynamic/updated content.
Here we have been using S3 bucket Service to serve requested Image content. To enable this you will need to install and configure plugins allowing to connect to S3 buckets, 1 out of many such plugins which can be used is “WP Offload Media Lite for Amazon S3 and DigitalOcean Spaces”.
The mentioned plugin allows you to connect your WordPress website to S3 bucket and also point a CDN (CloudFront in our case) to the S3 bucket so that the images hosted on your website need not be served all the way from your EC2 server hosting the website and instead be served by the respective CDN by calling the images from your S3 bucket.
This particular mechanism positively benefits the site loading speed because; all the requests are first bifurcated into 2 different types and 1 type of request is being served by CloudFront by serving cached image content from your nearest CloudFront Edge location and the other request is being served by your origin website server.
So in the above whole process your site load time can decrease to a percentage range of 75%-95% than it was as to before implementing this solution.
Lastly, the RDS server which hosts the database of your website is hosted into a “PRIVATE SUBNET” of your “CUSTOM-VPC” and VPC is Configured to allow only EC2-Server requests to be accepted and answered by RDS Server’s private subnet allowing no other public access to the database server in turn making your database server extremely secure against any unauthorized public access.
This solution and architecture will decrease your site load time as well as will reduce the traffic on your main website server resulting in it performing more efficiently and your website viewers being able to receive their requested content faster.
However, as mentioned in the beginning the architecture and solution shown here are in their most basic phase and you can add on services and functionalities as per your personal requirements to improve your site’s performance even more. For e.g. :- you can add load balancers and extra EC2 servers to serve other content requests as well as you can enable Multi-AZ deployment feature for your database server which will also help in serving content in case of failover of 1 availability zone, etc.
NOTE :- Now, the above used services are not exhaustive. This is just a bare-bones architecture which includes only the crucial services required for the website to serve content as fast as possible along with being secure as well as under minimum possible cost. For e.g.:- you can add more than 1 EC2-servers and keep a load balancer before them to balance the amount of requests being processed by each EC2-server in case your WordPress website experiences high traffic and heavy load for long durations and you can afford the cost for those services as well. If any point of time you feel that you need help of AWS certified solution architect and developer, you can always count on us.
Also Read: Backup WordPress site to AWS S3 bucket
Related Post: Step by Step Guide to Install WordPress on AWS for free
Services: AWS CLOUD MIGRATION SERVICES
As a Director of Eternal Web Private Ltd an AWS consulting partner company, Nirav is responsible for its operations. AWS, cloud-computing and digital transformation are some of his favorite topics to talk about. His key focus is to help enterprises adopt technology, to solve their business problem with the right cloud solutions.
Have queries about your project idea or concept? Please drop in your project details to discuss with our AWS Global Cloud Infrastructure service specialists and consultants.