The evolving situation caused by Covid-19 led Cuple to
rapidly establish its online shop over AWS Cloud
Services accompanied by a marketing campaign to inform
their clients about this continuity plan. As their
e-commerce kicked, the website received around 5,000
requests in a short time frame, and consequently their
website went down which unfortunately had their
infrastructure down because it couldn’t handle the
enormous traffic request growth without a highly elastic
and available cloud hosting environment. Cuple realized
the situation and decided to get consultancy from lead
AWS Partners in the region to accommodate higher traffic
volumes and upscale their infrastructure capacity
seamlessly. Zero&One team had to re-factor and
re-architect Cuple’s infrastructure by utilizing various
AWS tools and technologies such as Application Load
Balancer, Auto-Scaling, S3, RDS, EFS and CloudFront to
achieve a fully-functional design over a weekend
resulting in a successful campaign that can sustain
millions of requests during peak time.
Our team had to use AWS EFS; a cloud storage service
provided by AWS designed to provide scalable, elastic,
and encrypted network file storage to store WordPress
static folders such as wp-content and then mount it
across all servers behind the Autoscaling group. AWS EFS
was not the perfect solution for Cuple due to the burst
credit limits that was easily throttled by the PHP
application as a result of high IOPS utilization. To
overcome the high IOPS utilization, we had to either use
the EFS provisioned throughput mode or set up a RAID 10
array that can improve disk performance and data
consistency by utilizing the stripping and mirroring
features of RAID 0 and RAID 1. However, both solutions
will incur more charges on our client’s monthly bill.
So, we had to migrate the wp-content folder from EFS
back to the root EBS volumes and only mount the uploads
folder to EFS. Even though this approach had the
application get back on track, creating manual AMIs and
new launch configurations was obligatory after each
WordPress update that cannot be saved in the database.
Typically, updating an autoscaling group with a new
launch configuration had to be executed manually and
then older instances are gradually replaced with newer
ones across multiple availability zones. Several days
later and knowing the fact that Cuple team constantly
runs marketing campaigns along with several CMS plugins
updates, this manual process was identified as a risk
that is first and foremost time consuming and could
result in an unexpected application failure if
configured improperly.
Given the fact that all these activities had to be
executed in line with the marketing campaigns, Zero&One
team was able to achieve a fully-functional design over
a weekend resulting in a successful campaign that can
sustain millions of requests during peak time. Moreover,
at a later phase, Zero&One team kept monitoring
activity, reiterated, and optimized the design to lodge
more IOPs as Cuple had an even bigger campaign (10 times
the first) reflecting the flexibility and scalability of
AWS Solutions.
Knowing the huge traffic Cuple website was experiencing,
Zero&One engineers had to utilize Auto Scaling that is a
cost-effective solution by AWS that provides a
fault-tolerant and scalable infrastructure while keeping
the operating costs as low as possible. Load balancing
is crucial to achieving the benefits of auto-scaling and
this is where our team decided to use the Application
Load Balancer (ALB) for the WordPress CMS with content
routing to distribute the traffic evenly between EC2
instances. CloudFront was then configured to cache
static and dynamic content that in return delivers it to
end-users immediately if available in the nearest edge
location. Setting up CloudFront for WordPress required
one distribution, two origins, and several behaviors
targeting various WordPress files and folders such as
wp-content, wp-admin, and wp-login.php file where each
of these contents has a unique HTTP and caching methods
Moreover, AWS RDS for MySQL with multi A-Z were hosted
for the WordPress database that is a fully managed MySQL
database that adds more scalability and high
availability to the environment by replicating the RDS
instances between multiple availability zones. AWS S3
also improved the server’s utilization by storing
thousands of images in a restricted bucket that is only
accessible by CloudFront using origin access identity.
Zero&One DevOps team had to come with a solution that
can reduce the manual overhead by automating the whole
process using AWS Lambda, API Gateway, and some API
calls that AWS provides to end users out of the box. Now
how does all this work? Simply, invoke the Lambda
Function either through AWS CLI, API gateway with
authorization, or even from Slack using AWS Chatbot and
let the magic happen in a couple of seconds. AWS Lambda
offers a simple and straightforward serverless platform
that supports several languages such as Python, Java,
Node.js, C#, and more. For this tutorial, we will be
using Node.js to create our function.
Users will first provide IAM credentials to an API
Gateway via a post method to make sure that only
authorized personnel can invoke the lambda function.
Once the user is authorized and temporary credentials
are generated, API Gateway will invoke the Lambda
Function that will in return starts creating a new AMI
for the running instance, changes the launch
configuration settings, and then updates the Autoscaling
Group with the latest AMI.
Let’s now have a look at the TypeScript code.
First things first we have to import all necessary
modules that our lambda use and define the required user
input during a POST or AWS CLI request.
Then we declare an event trigger handler with some
identifiers and variables that first get the current
date, then parse the user input that should include the
current autoscaling group name and instance ID from
which the new AMI image is created by the ciResponse
variable.
Cuple team is currently expanding their cloud adoption on AWS through many regions with the help of our tailor-made automated AMI Factory that eliminated unexpected human errors and operational overhead. Cuple is currently running multiple weekly campaigns and performing several updates on its backend and frontend environments without affecting the digital e-commerce experience of its end-users. AMI Factory is with no doubt a rescuer for workloads that require consecutive changes on their running EC2 instances while utilizing a highly available and resilient cloud infrastructure on AWS without disruption.
Zero&One is a leading Premier AWS Consulting Partners in MENA region with a vision to empower businesses of all scales in their cloud adoption journey. We specialize in AWS services like DevOps, application modernization, cloud migration and serverless computing. We currently operate from our offices in Lebanon, UAE, and Saudi with 100+ certifications in our hands and serve 50+ happy customers across the region.