Re.life is a next-generation digital ecosystem created to empower both individuals and businesses across logistics, recyclables trading, and much more. Based in the United Arab Emirates, their portfolio of digital services is currently comprised of re.life Market and re.life Collect. Re.life Market is a virtual marketplace for business-to-business buying and selling of recovered commodities such as scrap metal, recyclable plastic, mixed fibers, and more. Re.life Collect is a platform for residents and businesses looking to move heavy, bulky items from one location to another, or to dispose of unwanted items.
Relife Collect was initially deployed in a fully serverless infrastructure utilizing AWS Lambda for its backend application. One of the most critical challenges developers have faced during their day-to-day code release is deploying new versions for more than 60 Lambda Functions running on the live environment where it has affected the end-user experience dramatically in an industry that expects almost zero faults as at some point it could result in a loss of money, time, and trust between Relife as a corporate and the clients. Despite all the benefits of serverless infrastructures and all the great features that come in handy in terms of low cost, high availability, and scalability; reducing the risk of software deployments is essential in a fast-paced industry that relies on hundreds of daily new releases to keep business moving in a highly competitive market that only focuses on user experience, customer satisfaction, and customer obsession.
Traditionally, developers used to publish new releases to the production environments by updating the lambda function code for version $LATEST or even pointing an alias to a new function version. Fortunately, AWS has introduced AWS Lambda Traffic Shifting and Phased Deployments with AWS CodeDeploy. This was definitely a game-changer and many DevOps Engineers started adopting this strategy for their day-to-day deployments. However, this was not the case for those who were using the Serverless Framework as it didn’t support this type of deployment process until the Serverless Plugin Canary Deployments has come into effect by implementing canary deployments of Lambda functions and making use of the traffic shifting Lambda feature in combination with AWS CodeDeploy.
Fortunately, the Zero&One DevOps Engineers were able to completely transform the new application release approach for Relife and guaranteed an almost zero downtime fully automated deployment strategy with the help of several AWS Services some of which we will discuss later in this case study.
As shown in the below figure, the architecture has been completely built using the Serverless Framework, which is an open-source software which that builds, compiles, and packages code for serverless deployment, and then deploys the package to the cloud. Moreover, the serverless framework has also been utilized to build serverless AWS services such as AWS Lambda, AWS Cognito, AWS API Gateway, AWS DynamoDB, and many more. Zero&One has introduced a fully automated CI/CD pipeline using AWS CodePipeline for the new deployment strategy knowing the many features that this service supports in conjunction with AWS Codebuild and AWS Codedeploy. Our solution depends on the Canary deployment strategy that is responsible for shifting a specific amount of traffic to a new Lambda version within a specific period of time until all the traffic is completely shifted to the new version.
So how does this exactly work in a fully automated CI/CD
pipeline?
Developers will still push new code to their GitHub repository
as usual but this time, CodePipeline will start a source stage
withing the pipeline to pull the latest code changes in a GitHub
branch, AWS CodeBuild on the other hand will start the building
stage by installing all the Serverless plugins and libraries and
execute the “sls deploy” command. At this stage, AWS CodeDeploy
will start deploying the latest code to a new Lambda version and
uses the “Live” weighted alias created in the previous build
step to distribute traffic between the latest version and the
currently running one gradually. Now here’s where the canary
deployment plugin comes into play by distributing the traffic
between the lambda versions and use the
Linear10PercentEvery1Minute deployment preference type to
gradually shift traffic within a 1-minute interval. Moreover,
CodeDeploy was also configured to monitor the Lambda Function
deployments status through Amazon CloudWatch so that it can roll
back to the previous running version if the “Error” monitoring
metric triggers a CloudWatch alarm which indicates that the
function has either fail due to timeouts, memory issues, or
unhandled exceptions.
Finally, Relife has been constantly deploying dozens of new releases daily with a zero fault recorded resulting in a highly available and fault-tolerant fully automated serverless application running on AWS that requires way less human efforts from the DevOps and development team and more importantly providing the business with more confidence that building serverless applications on AWS cloud satisfies the required quality, and performance as well as enabling faster response to business changes.
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.