AWS Cost Optimization and Monitoring
7 AWS Services for Cost Optimization and Monitoring
January 2, 2022
Easily Migrate from EC2-Classic to VPC
June 16, 2022
Show all

Deploying/Migrating your WordPress website to Serverless Environment on AWS

SUDO Serverless Wordpress

Welcome to the world of “Serverless WordPress” on AWS

Imagine you have great idea and you want to publish it as a website. Or your team is managing a crisis like a pandemic and wants to publish public interest health information quickly. These scenarios may pose a challenge in terms of speed, and difficulty determining the capacity required. You may end up over provisioning or under provisioning and struggle for optimal cost performance ratio.

This blog post will help to remove the complexity and by the time we are done, you will have a production scale environment for your website.

 

Common challenges in deploying or migrating WordPress Website

  • Infrastructure sizing compute and database storage, normally end-up as guess work. You either over provision or under provision.
  • Managing traffic spikes and scaling to meet demand
  • Making the website architecture highly available & resilient to meet SLA’s
  • Adopting industry best practices for Security and Compliance
  • Managing outages and migrating complex customised scenarios

 

To address some of these challenges, AWS offers native services and tools, like Infrastructure as code and autoscaling for EC2 instances. Even then, planning designing, optimizing for performance, operational excellence and overall cost could still be a complex engagement/project.

Hence the need for a better approach, introducing;  The Complete Serverless Website Infrastructure,  Serverless Database included. Now that is Amazing!

Here is the proposed architecture, based on AWS Well Architected Framework, covering all pillars; Operational Excellence, Security, Reliability, Performance Efficiency, Cost Optimization and Sustainability.

A note on Sustainability, Hosting your website on AWS, reduces your organization’s carbon footprint. AWS uses 88% of total renewable energy to run AWS Cloud infrastructure.

 

SUDO Serverless WordPress

The above diagram and solution cover the following services

  • A highly available architecture that spans two/three Availability Zones*
  • A VPC configured with public and private subnets, according to AWS best practices, to provide you with your own virtual network on AWS*
  • An Amazon Route 53 record entry for provided Hosted zone Id. (optional)
  • An Amazon ACM public certificate for HTTPs connection. (optional)
  • An AWS Web Application Firewall using AWS Managed WAF rules for protection against SQLInjection and common WordPress exploits
  • An internet gateway to let traffic in the VPC
  • An ELB Application load balancer targeted to the ECS Cluster Auto scaling group.
  • An Amazon Aurora Serverless database connected to the Containers
  • An AWS EFS File System for storing WordPress files, themes and plugins
  • An AWS Secrets Manager secret to store the Amazon Aurora database password
  • NAT gateways to allow outbound internet access for resources in the private subnets*
  • AWS ECS Fargate containers running WordPress, which communicate with the Aurora serverless database and the Elastic File System

 

To make life easier, SUDO Consultants in partnership with the AWS I&A team, built a Serverless WordPress AWS Quick Start to ease the process of creating, resilient, secured enterprise grade WordPress sites.

AWS Quick Starts are ready-to-use accelerators that fast-track deployments of key cloud workloads for customers. These accelerators reduce hundreds of manual procedures into automated, workflow-based reference deployments for AWS Partner technologies, built according to AWS best practices.

 

Features:

The Quick Start creates infrastructure as code using CloudFormation allowing users to make configuration changes and support for roll-back. It also incorporates security at all levels using AWS WAF (Web Application Firewall), security group chaining, subnet segregation and by enabling encryption to protect data in transit and at rest. Furthermore, it leverages managed services in a multi-AZ architecture to provide high availability and to ease the failover process. The serverless architecture allows resources to scale horizontally when needed instead of guessing capacity and paying for over-provisioned resources. When using managed services, implementations are easier for your team by delegating complex tasks to AWS.

We use AWS Fargate as it removes the need to provision and manage servers. You only pay for the resources required to run your containers, so there is no over-provisioning and paying for additional servers. We use ECS Service Auto Scaling to maintain the level of performance for your application as its load increases or decreases. We use Amazon Aurora Serverless which automatically starts up, shuts down, and scales database capacity based on your application’s needs. It allows you to run your database without managing servers. We use Amazon Elastic File System which is a high performance and durable filesystem as a shared storage layer, this allows our WordPress containers to have shared storage.

Launching the Serverless WordPress from AWS Quick Start catalogue

Deployment takes about 10-15 minutes to complete. Following the below link to deploy, serverless Quick Start in your AWS account.

https://aws.amazon.com/quickstart/architecture/sudo-consultants-serverless-wordpress/

Instructions on next steps and deployment guide are here.

Migration Approach 

Now that, you have serverless WordPress running on AWS Fargate and backend Database as Amazon Aurora serverless. And now if you want to migrate your existing WordPress site following sections provide few options to migrate your existing WordPress website to the new serverless WordPress.

Simple Import/Export Content Migration

Assuming your present WordPress website running on On-Prem server or Amazon EC2 instance in Cloud and you want to migrate this to Serverless WordPress environment.

Use WordPress built-in simple import/export content migration, you can migrate your existing website content by exporting from the existing website (from EC2) and importing to new WordPress which is deployed by using this Quick Start.

You can find export and import option inside WordPress Tools menu.

Third party WordPress Plugin

Using Third party WordPress migration plugins you can export and import or do live migration, there are lot of different plugins available in the WordPress plugin directory. Specific plugin recommendation is out of scope of this blog. However, you review and use any of the plugins as appropriate with your WordPress version.

Complex scenario Migration

For complex database schema or a customised WordPress website, you can utilize combination of following AWS Services to migrate the website and implement completely automated CI/CD based deployment.

  • Using version-controlled code repo like GitHub or code commit for WordPress files
  • Setup a pipeline using CodePipeline
  • Build the container image using CodeBuild
  • Deploy the container image using CodeDeploy
  • For Database migration, using AWS DMS service for seamless database migration to Amazon Aurora
  • If there is requirement for schema conversion, SCT (Schema Conversion Tool) help to convert to target schema
  • For static contents, and flat files, AWS DataSync service can be configured to copy to AWS EFS in AWS

If you need any help with any of the scenarios or complexities SUDO Consultants could help even with setting up complete CI/CD based deployment model, feel free to contact SUDO Consultants and we will be more than happy to assist you.

 

Clean Up: In your account from the CloudFormation console, select the WordPress stack and choose Delete.

Authors

Datta
Sadwelkar, Dattaprasad
A Managing Consultant and Solution Architect, with a background in Network and Cloud Security, passionate about solving complex problems by Innovation and Transformation. Advocate Target State acceptance, ensuring compliance and security controls and extensive automation, SOAR.
Saif Ali
Saif is a certified AWS engineer with a focused on automation
Hameedullah Khan
Hameed is the CEO of SUDO Consultants with years of experience in build large scale clouds

Leave a Reply

Your email address will not be published.