Amazon Web Services (AWS) is the most popular and robust Cloud Hosting Infrastructure. Millions of sites and some of Internet’s most popular sites, portals and eCommerce Sites run on Amazon.
Deploying Magento Enterprise on AWS for serving millions of users and a large catalog size would require a deeper understanding of Magento and AWS.
This article talks about the architecture and points to consider while deploying Magento Enterprise on AWS.
The diagram below shows a recommended minimum architecture to deploy Magento for High Concurrent Traffic.
Given the architecture above the following points / settings need to be considered while setting up the servers
Make your App Servers Stateless:
What this essentially means is ensure that none of the user specific information like sessions, shopping bag contents etc are not stored on the server. The sessions storage must be moved to the DB or Memcache. This will allow you to easily add or remove an app server, without the online users getting logged out out or losing their shopping basket contents.
Do not enable sticky sessions on the Load Balancer:
A load balancer is usually programmed to re-direct users to the app servers on a round robin method. However if sticky sessions are enabled then the load balancer will direct all traffic from one user to that one single server where his session is created. While this works fine in most cases, there could be scenarios where the users connected to one server would be more active than the ones on the other, this would lead to an overload of one server while the other is relatively low on load. This would obviously affect the response times for users connected on the loaded server.
Ensure that the Media Folder is stored in an S3 bucket and it served via Cloud Front.
I’ve seen many deployments where the media folder, which contains all the product images and other static content is being duplicated across the multiple app servers and is being rsynched each time a change happens. This is not ideal as the replication take times and while users would be able to see the images, the other would not be able to. The ideal way is to have the media folder on a S3 bucket and have it served via Cloud Front (CDN) so that the images are served from the nearest node.
Put your CSS and JS also on CloudFront:
Well that’s a no brainer, all static content should be served out of cloudfront. Don’t forget to concatenate, merge and minify the JS and CSS files. Magento is notorious to have 12-16 different JS files. in their default and Enterprise themes.
Enable IOPS for your RDS database:
Relational Database Service (RDS) is usually the most preferred way to get your MySQL on AWS. RDS will make it really easy for you to get your database in Master Slave mode, and schedule automated data backups. However RDS can turn out to be a bottle neck when it comes to high read writes to the DB which Magento does a lot. This is because the RDS is essentially stored on a SAN which comes with its own latency problems. The one way to overcome that is to enable IOPS for RDS to make sure the app servers can read and write data to the RDS database sufficiently fast.
CPU over RAM:
Magento users a lot more CPU than it uses RAM, so while choosing an Instance try and go for one that gives you more CPU power than RAM.
User a Memcache server this will significantly improve the sites performance. Also importantly ensure you have a bank of memcache servers running and have it properly configured in Magento, else your memecache server can become a single point of failure.
Use Nginix instead of Apache:
During most of our load tests, we notice the web servers being overworked most of the time and using most of the CPU power. Nginx has a much smaller foot print as compared to Apache and can server a significantly higher number of concurrent users than Apache.
Varnish can be a double edged sword:
Many architects think simply throwing in a reverse proxy like varnish before the app servers will help boost performance, that’s quite wrong. Putting Varnish in front of Magento Enterprise with full page caches on can actually be counter productive especially if Varnish is configured to server only images and static content. In many scenarios its actually good not to use APC instead of Varnish to improve speeds.
xDebug comes default within the Magento Installation and is quite useful for debugging the application during development. However it will slow down the site while running in production mode. Significant performance benefits can be achieved by disabling xDebug in Magento.
With the above configurations we’ve been able to have our Magento Enterprise Portals server 50+Million visitors with under 5 seconds of page load times during peak loads.
Disclaimer: The company I work for is partners with several vendors