Deploy a Production-Ready E-Commerce Solution on AWS With Cloud Formation


E-commerce platforms like Shopify have dominated the e-commerce industry for many years due to their low upfront setup costs and ease of use.

However, after a recent engagement with a large online merchant, our team found two significant reasons as to why a commercial solution such as Shopify may not always make sense for an organization:

  1. Fees: Due to the scale of your operation, the fees incurred by Shopify may not make sense financially

  2. Customization: Your E-commerce strategy requires modules/plugins (punch-out integration, internationalization, etc..) that are specifically customized for your organisation's strategy.

At this point, most organizations turn to Open Source based solutions, but this is no small undertaking because of the work involved. You need to figure out how to setup and configure servers, domains, plugins, backups, databases, and more. Simply put, the current experience deploying Open Source based e-commerce solutions is the exact opposite of what it takes to deploy a commercial solution. 

Realizing this largely unsolved problem in the industry, our team at HADII developed a set of CloudFormation templates to deploy a full-fledged, battle ready, production quality PrestaShop based e-commerce solution in the AWS cloud in one click!

Best of all, we open sourced all of our code on GitHub! Check it out there or deploy your own e-commerce store by clicking the “Launch Stack” button below!

If you need help deploying your e-commerce solution and are finding the same challenges described above, reach out to us to see how we can help! The remainder of this article will cover the design and advantages of our approach.


Solution Design

Being a software-focused project, PrestaShop lacks many of the capabilities a full-fledged e-commerce store requires in order to be successful out of the box. This was the driving factor behind our decision to develop a set of CloudFormation templates that enhance a containerised PrestaShop application by provisioning the necessary AWS infrastructure around it to provide backups, auto-scaling, multi-zone availability, security, metrics and logging.

In this solution, PrestaShop is deployed as container workloads in an auto scaling cluster using Elastic Container Service (ECS) over two Availability Zones (AZ). This helps our cluster remain Disaster Recovery (DR) proof, since our solution can withstand an entire data centre going down. The architecture for the deployed infrastructure is illustrated below.

architecture_diagram

Additionally, each container in the cluster mounts specific shared PrestaShop install directories from an Elastic File Storage (EFS) instance that is automatically backed up regularly using AWS Backups. EFS is a great choice here as it is designed to provide massively parallel shared access to thousands of instances at the same time, and has DR built in as well.

The primary PrestaShop database is deployed using the Relational Database Service (RDS) from AWS, and can be configured for Multi Zone availability as required. Backups of the database are automatically stored in S3 on a daily basis.

The last key component of the entire solution is CloudWatch, which provides logging and metrics required to monitor and scale the entire ECS cluster in response to certain metric thresholds. By default we've created CloudWatch alerts which will increase and decrease the the number of containers running in the ECS cluster in response to sustained CPU/Memory thresholds in the cluster.


Perk #1 - Scalability

There's a common theme amongst the most popular Open Source e-commerce solutions in which they’re designed as monolithic systems that scale vertically. This is expected to some extent, since many of these projects were initiated over two decades ago before compute abstractions like containers and serverless functions existed.

The architecture for PrestaShop 1.7 as illustrated below is pretty sophisticated, and it's all meant to be deployed on a single server (minus the database). PrestaShop has some guidance on scaling a PrestaShop instance which includes things like optimising the settings for PHP, Database, Apache, cache, & PrestaShop itself. However, as you probably noticed, these recommendations are focused on enhancing the performance of PrestaShop more so than they are focused on addressing the issue of scalability.

The fact is, if Prestashop is performing sluggishly, the server needs to be scaled vertically by increasing the amount of compute resources available to it. The problem with this model is that mid to large sized e-commerce websites cannot afford to do it, since it requires the machine being upgraded to be taken offline temporarily while compute resources are increased.

Because of this limitation, companies are forced to either inconvenience users with downtime, likely at peak usage times, or pay large penalties in the form of largely unused, compute resources 24x7 to avoid incurring downtime associated with vertically scaling.

By deploying PrestaShop as container workloads in ECS and scaling the cluster in response to CPU/memory thresholds using CloudWatch, PrestaShop will scale horizontally as opposed to vertically. Rather than “beefing up” running containers which is typically done in legacy systems as described above, we’ll add and remove containers to and from the cluster dynamically in response to user traffic activity.


Perk #2 - Disaster Recovery

DR is built into all aspects of the infrastructure as outlined in the previous section on our solution’s infrastructure design. The ECS cluster itself is deployed over two Availability Zones, along with our internet facing Elastic Load Balancers (ELB). The file storage mounted by the containers in the cluster rely on EFS which is DR compliant. Lastly, the Database is deployed on RDS which can be configured to multiple Availability Zones as well.

In the case the database or PrestaShop itself needs to be restored, backups can be fetched and restored at the click of a button from S3 or AWS Backups respectively. While backups are taken on a daily basis by default, this interval can be modified to satisfy the Recovery Point Objectives (RPO) for your specific DR strategy.

Overall, the infrastructure deployed through our solution has Multi-Site DR built into all of its components minus the RDS based PrestaShop database which incorporates a Warm Standby DR strategy. While there is additional costs associated with these fail over provisions in place, this cost is offset by a minimized Recovery Time Objective (RTO). That is, in the event of a disaster, the lack of DR compliant infrastructure could arguably end up being much more costly to your business.


Perk #3 - Monitoring & Alerting

CloudWatch stores all the metrics being generated by our ECS cluster including but not limited to those involving CPU and memory utilization. Administrators can view these metrics through a convenient dashboard and even configure alerts to take some action when certain threshold are crossed, such as sending an email or an SMS text message.

Another such action that can be taken is to modify the size of our ECS cluster, which effectively gives us the ability to dynamically scale our PrestaShop cluster up and down in response to the load being placed on it.

Needless to say, this auto-scaling capability allows businesses to optimally solve the problem of providing their customers with the best possible experience on their website while minimizing costs incurred.

Deploy in One Click, From GitHub!

At the beginning of this project, our team at HADII set out to provide businesses with the ability to deploy an OpenSource based e-commerce store with many of the features of a commercial e-commerce solution in an effortless, automated manner. By relying on CloudFormation templates and the breadth of the AWS platform and its services, we were able to deliver just that.

All the code we developed is freely available on GitHub for you to use in your own projects! If you need any help using what we've created, or with delivering your e-commerce strategy in general, feel free to reach out to us. To keep up to date with HADII’s latest projects and works, follow us on twitter and subscribe to our mailing list below.

 
 

Subscribe.

 
Previous
Previous

4 Elements of a Great Serverless Application Deployment Strategy

Next
Next

Non-Profit Growth - Start By Asking Big Questions.