Running Magento in AWS Environment – Best Practices

amazon-web-services

Hosting Magento, as everyone knows, isn't like hosting other PHP applications. How feasible is it to run Magento in an Amazon Web Services environment in 2013?

What magic combination of AWS services does it make sense to use with Magento? What levels are smart defaults for a "run of the mill" store? (yes, I know, there are no run of the mill stores)

Which ones (EBS?) should be avoided?

Any tips, tricks, deployment strategies to avoid weeks of pain getting this setup?

Best Answer

I was hosting Magento on AWS in 2011 until 2013. Many of the things you gain from using cloud infrastructure rather than traditional dedicated or shared hosting are more relevantly described under the topic of DevOps, which are not exclusive to AWS but are more easily enabled through its use.

  • Complete and flexible control of your capacity planning -- scale up ahead of marketing events, enable dynamic provisioning via Elastic Beanstalk, scale down during low volume periods, spin up a site in a couple weeks, tear it down and throw it away.
  • Easily setup dev/test/staging environments and replicate changes between them.
  • Host your admin pages on a separate host.
  • Use DynamoDB for session management and ElastiCache for cache w/o incurring additional operations overhead, beware ElastiCache doesn't currently function in VPC though.
  • use ELBs for loadbalancing, but beware if requests take more than 60 seconds they'll be terminated ungracefully
  • Use AmazonSES for sending emails (now even easier via regular SMTP), though gaps still exist in tooling for tracking bounces/complaints
  • Use AmazonS3 for hosting media, and Cloudfront for CDN.
  • Reduced operations cost for database activity via RDS, which features point in time restore, automated failover, automated backups, and automated upgrades.
  • DNS management is super easy in Route53, but generally recommended for ease of mapping subdomains to load balancers.
  • VPC to put all your machines on their own private network to have more granular control and expose access as you see fit via your own VPN tunnels.
  • Easy performance metrics and alerting (aside from memory usage and disk usage) via CloudWatch & SNS

Minimal footprint will be 1 ELB, 2 EC2 webservers in seperate AZs, 1 multi-az RDS, Route53 hosted zone for the domain. Initially you can use sticky sessions on the ELB to keep session management simpler, but as your traffic increases you'll want to move media into a CDN (S3 & CloudFront) and sessions off of the individual machines.

Areas I haven't looked but still are promising: CloudFormation scripts for easier deployment of a Magento stack, offloading order creation via DynamoDB and worker queues for greater checkout throughput (someone has already started a project to do this via MongoDB at one of the hackathons recently), and setting up a multi-region presence via latency based routing with Route53.

I guess I'm kind of an evangelist for cloud. Specific to AWS, c3.large are a decent instance size for production webservers, but I'd start off with the smallest of each instance class and measure performance and scale up or optimize code as you see fit, which is why I refer everyone to xhgui constantly.

Related Topic