1001010110101010
Thank you! Our team will contact you soon

Automation in the Cloud

  • Industry : Retail
  • Country : UAE
aws
serverless
next-generation
cdk
automation

Cuple is one of the well-reputed retailers in Dubai specialized in footwear, bags, and perfumes for all age groups and genders - distributed across 15 branches in all UAE. Cuple offers a wide variety of collections in an up-to-date fashion provided that they are a Spanish brand that is always aiming after the latest European Trends. And recently, due to Covid-19 lock-down measures, Cuple initiated an e-commerce store to be able to sell their products online.

Keep the market ready!

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, although it was not the perfect solution for Cuple due to the burst credit limits that got easily throttled by the PHP application due to 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 the 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.

Innovate or Depreciate:

Given that all these activities had to be executed in line with the marketing campaigns, the Zero&One team achieved a fully functional design over a weekend, resulting in a successful campaign that can sustain millions of requests at peak time. Moreover, at a later phase, the 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, 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. Our team decided to utilize an 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 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 wp-login.php file where each of these contents has a unique HTTP and caching methods. Moreover, AWS RDS for MySQL with multi-AZ was hosted for the WordPress database to add more scalability and availability for the environment by replicating the RDS instances between multiple availability zones. AWS S3 has 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.

Why care about automation?

Zero&One DevOps team had to come up 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 or API gateway with authorization and let the magic happen in a couple of seconds.

Users will first provide IAM credentials to an API Gateway via a post method to ensure 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.

Moreover, our DevOps engineers decided to deploy this application using the brand new CDK Pipelines Library that AWS has announced in July 2020 and is currently in developer preview until it is ready for general availability. Zero & One embraced many CI/CD and Infrastructure as Code tools to help clients provision their infrastructure, code delivery, and deployments more efficiently and consistently to yield positive impacts on the internal working efficiency and reliability.

AWS Cloud Development Kit (CDK) is a powerful tool that is mainly used to achieve all the DevOps requirements by building solid foundational cloud infrastructure as code using modern programming languages and also allow developers to create a complete CI/CD pipeline that can help them deploy their cloud services promptly.

Yet, our team at Zero & One continuously innovates with new technologies and constantly adopts it to help clients benefit from the latest updates and announcements and provide an easier and faster way for managing their applications and cloud environments following AWS best practices. CDK Pipelines is a great new Library powered by AWS CodePipeline that has broken down creating CI/CD pipelines and CDK applications across multiple regions and accounts while simplifying the cloud application development as much as possible by writing less code and putting fewer efforts. In a nutshell, CDK Pipelines will preconfigure a CodePipeline pipeline for you, consisting of several stages to deploy your CDK application. However, the account and Region combinations you want to deploy have to be bootstrapped first so that the CDK can access it.

As soon as the pipeline is created, a Source stage where our CI/CD and application source code is stored (GitHub) will get built, and a SimpleSynthAction.standardNpmSynth action is then defined to generate our CodeBuild stage to install, build and synthesize the CloudFormation from our CDK application. In other words, the SimpleSynthAction will create a build stage in our CodePipeline that will run several commands for us, such as npm ci, npm run build, npx cdk synth, and then saves our pipeline project in an Artifact directory. Third, a UpdatePipeline build stage is also configured for us that is responsible for updating the CodePipeline itself based on our latest code and by simply running a cdk deploy command in a buildspec file. Now that our CI/CD pipeline is ready, our next step will require creating a new stage to deploy our infrastructure, including AWS Lambda and AWS API Gateway. To achieve that, we have simply appended a new stage in the pipeline to deploy our application stack.

By the time our code is pushed to GitHub, CodePipeline automatically starts the CI/CD pipeline for us and creates three new stages that will first convert our TypeScript code to JavaScript and then compress and store it in an AWS S3 bucket to get consumed in the deployment stage. Next, a CloudFormation changeset is created in the preparation stage to preview how the stack changes might impact our running resources. Our team has also configured a manual approval action before starting the deployment stage to make sure that CodePipeline will deploy and update exactly what they have pushed to their GitHub repository. Finally, the CDK Pipeline will create the deploy stage using the CloudFormation deploy action and provision our serverless application in an automated manner.

In Conclusion

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 back-end and front-end environments without affecting its end-users digital e-commerce experience. Without a doubt, this solution was a rescuer for workloads that required consecutive changes in their running EC2 instances while utilizing a highly available and resilient cloud infrastructure on AWS without disruption. It is worth saying that the CDK Pipeline played a major role in creating and maintaining this solution by allowing us to deploy it into multiple accounts that Cuple is constantly adding on the AWS Cloud.

About Zero&One

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.

01
Contact Us

We'd like to hear from you

Protect yourself and others from the covid-19 pandemic. Learn more