We see a lot of traction among e-commerce startups to use cloud platforms like AWS, Azure and Google to host their website. Some top e-commerce sites like Snapdeal, Zovi, Zivame and Amazon (obvious) run on cloud platforms quite successfully even though these cloud platforms are not in India.
So what are the compelling reasons which e-commerce startups consider when planning for cloud based hosting?
- High availability options
- Auto-scaling features
- Automation in backups, deployments, databases etc
- Performance & reliability
- Reduced GTM time
- Pay-per-use model
and many more..
But most of the above can be achieved only if the architecture is designed to support the awesome features of cloud. So in this post, we will focus on the architecture design and other PaaS solutions which can blend in with an e-commerce website.
E-Commerce is all about images
Agree or not, your e-commerce site is only as good as the images. So the quality of images and the speed at which it renders plays an important role in defining the success of your website. Keeping this mind, cloud platforms provides massive object stores like Amazon S3, Azure Blob and Google Cloud Storage to help e-commerce sites host millions of images and link them with their app code-base.
In a typical data center or VPS based hosting, your images may very well lie in the local hard disk. But in cloud, the images are stored in these object storage PaaS platforms and rendered directly to the end user. So what's the advantage? In AWS, the Amazon S3 storage has native integration with Amazon CloudFront (AWS CDN Service) and this helps rendering the images to end users directly over CDN without hitting the web and app servers again thus bringing down the load on these servers.
How can I integrate my e-commerce application with S3?
It's pretty straight forward.
- Create a S3 bucket to store your images.
- Upload the images to the bucket using a third party S3 browser or through AWS console.
- Use the API provided by AWS to integrate your web-app servers with S3.
- Enable CloudFront to speak to S3.
- You are done.
Single box approach vs Multi-tier approach!
The other dilemma faced by application and infra engineers of an e-commerce application is the choice of architecture design when moving to cloud. The single box approach where you have all your application tiers - web, app & database in a single server brings in high risk of SPOF - Single Point of Failure. Here is where cloud comes in handy. Now you can run a highly distributed, highly available setup by replacing a single box approach to a multi-tier HA approach. A typical 3-tier web application running on AWS looks like the one below,
So how does this work?
- The user requests hits the DNS service of AWS (Route53) and the then the load balancer.
- The requests are parsed by the web and app servers.
- The corresponding images are rendered from S3 using Amazon CloudFront.
- The servers are setup in Multi-AZ (2 different Availability Zones) mode to ensure that even if one availability zone goes down, the site continues to work.
- A NAT instance for secure access by deployment & development engineers.
- Auto-scaling is enabled at web and app tier to handle spike in traffic.
Alternately, you can also plan for a 2-tier approach (like the one below) if separating web and app tier turns out to be a time consuming one.
So the checklist goes like,
- Ensure that your application can be implemented in 2-tier or 3-tier model.
- Replace Amazon S3 APIs for object storage (images, videos, files) in the application code.
- Setup a staging environment, deploy the new codebase and test for functionality.
- Use the AMIs (Amazon Machine Images) to create the production setup and make DNS changes while going live.
Hope this gives you a fair idea on hosting or migrating a highly available e-commerce application on cloud. Please contact us for any queries or help in setting up your e-commerce portal on cloud.