Ask the Expert: Setting up Magento 2 with AWS

By Alex Husar

Magento is a leading CMS for eCommerce projects with over 250,000 merchants worldwide relying on the platform to run their online stores.

To give you an idea of how popular it is, more than 20% of the companies from the “Top 1,000 Retailers list” are among Magento users.

However, advanced functionality, scalability, variability of features, and a multi-server environment come at a price. And the price, in this case, is the resource-intensiveness.

The truth is that if you have ever had an intention to run your Magento store on a shared hosting at $5/month, forget about it.

If you want your store to operate seamlessly and smoothly, to support a large number of visitors and orders per day, you need a more advanced hosting solution such as dedicated VPS or cloud hosting.

As such, Amazon Web Services (AWS) provides a synergy of hardware and software configuration, as well as data caching, and is considered to be one of the most optimal solutions for Magento stores.

Six reasons why Magento and AWS are a perfect match

  • As your Magento store grows, you will need more power, space, and memory for the website. With AWS, you can change the type of instance as per your business goals with just a click. Judge for yourself, the best way to handle those Black Friday traffic spikes is having the ability to scale your server to deal with the extra load.
  • Unlike many traditional hosters that often make new servers ready after 48-96 hours, you can start using the created instance on AWS immediately.
  • Amazon invests millions of dollars in its data centers located all over the globe to provide the best infrastructure and fantastic performance.
  • With AWS cloud hosting, the cost will vary depending on your usage. You will pay only for the amount of storage that you need.
  • Apart from physical security, each of Amazon’s services is architected to be safe and includes a set of capabilities that prevents unauthorized access or usage. Everything within the data centers is state-of-the-art to ensure the safety of both the stores and its customers.
  • Amazon provides a variety of services to make any store hosted on the AWS cloud work great: Elastic Compute Cloud (EC2) which delivers scalable compute capacity; Amazon CloudFront, a web service for distributing content with low latency; Route 53, a scalable DNS; Simple Storage Service (S3) which is a storage that is designed to make computing easier for developers; and so on.

Now it’s high time to find out what strategies can be applied to set up a Magento store on the AWS cloud. Each of the strategies is tailored to different kinds of online stores as per the number of their orders and visitors. Moreover, you can choose and apply an optimal strategy from “mildest” to “the most severe” in accordance with your set skills.


Practical advice from AWS experts to help you weather the storm

With extensive insights, advice, and best practices from cloud leaders, our brand new white paper is the ultimate guide to optimizing your business with AWS.

Click here to download the white paper now
Complete the form below and we’ll send a copy straight to your inbox.



Three ways to set up a Magneto store on AWS

#1 Download a Magento stack from the Marketplace

This strategy is as simple as they come. It can be put into action by even the most out-of-their-depth Magneto user without the need for development skills. You can easily run an eCommerce store on AWS in a few minutes by downloading and installing a scalable Magento 2 stack from the AWS Marketplace. The stacks you can find there were made by third-party developers who have configured an EC2 instance on AWS, saved their settings, and made them accessible for ordinary users.

These ready-to-run solutions can save you time and money, making them extremely useful for those who run a small-sized online store and have no technical skills. If you’re an owner of a large-scale online store, this solution isn’t the best choice for you (in this case, you’d better go with the third strategy).

Here’s how to download a scalable Magento stack:

  • Go to AWS Marketplace
  • Type “Magento 2” in the search bar
  • Use the filters within the Marketplace to sort out your results by instance type, region, architecture, average ratings, operating system, and other parameters
  • Select the solution that meets your requirements
  • Install the stack

#2 Launch an EC2 Instance on AWS with subsequent adjustment

With this strategy, store owners launch an EC2 Instance on AWS and work with it as if it were a regular VPC or dedicated server. What is an EC2 Instance? It’s a virtual server on AWS that’s able to run web applications. To put it another way, an Elastic Compute Cloud is an offering from AWS that allows users to rent virtual servers to deploy their websites.

This method is not quite so straightforward as the one above; implementation of an EC2 instance requires not only technical skills but code knowledge and the ability to use some software.

This strategy works well for small and middle-sized online stores as well as for test and production websites.

Here’s how to utilize an EC2 instance:

  • Create an AWS account
  • Navigate to AWS Management Console and launch an EC2 Instance
  • In the Console, select a virtual machine
  • Choose an Instance type depending on how much RAM you need for running your Magento store. You should note that Magento 2 has minimum requirements for VMs: no less than 2GB of RAM and a dual-core processor. An EC2 instance with at least 4GB of RAM is a safe bet for small online stores
  • Install the software
  • Launch your instance

Now, when an EC2 instance is launched, we can get to the installation of all pre-requisite tools that are needed to run a Magento store. What are these tools?

  1. PHP environment
  2. MySQL (or MariaDB) Database
  3. Web server software (Nginx, Apache, etc.)
  4. Cache software (e.g. Redis)

Installing software on an EC2 Instance is no different from installing on regular dedicated or VPS hosting. You can find step-by-step instructions here.

More AWS talent than anyone else

Take a look at our database of pre-screened AWS professionals and take the first step toward landing the best administrators, developers, and consultants in the market.

Browse AWS professionals

#3 Set up Magento on AWS using the cloud capacities to their full extent

And last but not the least, this strategy is a great solution for large-scale Magento websites with high traffic volume and visitor numbers.

It’s the trickiest way to set up Magento on AWS but the one that gives you the most options. To implement this method, you’ll need either good DevOps knowledge or a developer who knows the ropes.

Here are the components you’ll need:

Load Balancer

AWS Elastic Load Balancer is a service for distributing incoming application traffic among different EC2 Instances. The ELB is a big deal when it comes to providing a higher degree of fault tolerance.

EC2 instances

The same instances we mentioned earlier. Check out AWS’s guide to EC2 instances if you want to find out more.

RDS

Amazon’s Relational Database Service is a distributed relational database service used to make it easier to operate, set up, and scale a relational database in the cloud.

ElastiCache

ElastiCache is a fully managed cache service and data store provided by AWS. ElastiCache retrieves information from the in-memory cache, helping to improve the performance of applications by removing the need to rely on slower disk-based databases.

Now we know the what, let’s move on to the how.

Step #1: Set up Load Balancer, EC2, and Auto Scaling group

The owners of large-scale online stores have to deal with a great amount of inbound traffic, which can become even greater during seasonal peaks or sales.

Because of this fluctuation in traffic, some large-scale stores will need to create multiple EC2 instances with Amazon EC2 AutoScaling. This service enables developers to increase or decrease the number of web servers in a group as and when the needs of their website change.

When you have more than one instance, it’s essential to get a load balancer that can distribute request traffic among instances. When a new server is added to the auto-scaling group, the load balancer begins to send requests to it.

You’ll then need to create an Auto Scaling group that contains a batch of EC2 instances for automatic management and scaling. The group’s size will depend on how many instances you set aside to cope with your desired capacity. You can adjust the size both manually or with automatic scaling.

Creating a group allows you to utilize other AWS scaling features, like scaling policies or health check replacements which replaces unhealthy instances with the new ones. If you want to know how to create an Auto Scaling group using a launch configuration, you can read here.

You’ll need to install a PHP environment and a webserver to do this.

Step #2: Set up RDS

The next step within the strategy is to create an RDS DB instance to store the data used by your website or app.

The easiest way to do this is to use the AWS Management Console, which allows you to create a DB instance that uses MySQL, MariaDB, or other databases. After the DB instance is created, you need to connect to a database on a DB instance using standard MySQL utilities. Here you can find detailed instructions on the process.

Remember, your RDS instance has to be set up in the same Availability Zone as your EC2 instance.

Step #3: Set up Elasticache

You also need to set up Elasticache (Redis) to store sessions data and cache. This provides you an optimized end-to-end software and hardware stack for fast performance, enhanced scalability, and high availability. Find how to set up Redis here.

The easiest way to configure EC2 instances

Of course, you can take care of all the settings manually but you can also use tools that allow you to describe your environment in the form of a config. This makes it easy to make changes and saves time if you need to recreate the environment.

To do this, you can use AWS OpsWorks, which lets you create configurations and define the connections with the EC2 Instances.

OpsWorks is built for DevOps users and system administrators in search of an authoritative and end-to-end configuration management solution to help them control and customize environments.

TerraForm—a third-party utility that can work with AWS API and manage a stack—is a good alternative to OpsWorks.

Ready to get started? As you can see, there are a number of ways to set up Magento on AWS. Which one is right for your store depends on the size of your store and how much traffic you pull in (as well as your cloud knowledge and development skills).

Since Magento is designed to provide performance and scalability, AWS is a great option when it comes to hosting Magento online stores.

AWS is super scalable, making it an efficient solution to managing the seasonal traffic swings that occur with many eCommerce stores. It’s also secure, providing significant protection for stores and their shoppers, with millions invested in the defense of AWS data centers.

If you’re considering using cloud services to power for your Magento website, AWS is the perfect solution.

Setting up Magento on AWS is not always the easiest task, so if you don’t think you can tackle it alone, be sure to hit up a professional for support.

About the author

Alex Husar, a CTO at Onilab with 8+ years of experience in Magento and Salesforce. He graduated from Czech Technical University and obtained a bachelor’s degree in Computer Software Engineering. Alex’s expertise includes both full-stack dev skills and a strong ability to provide project-critical guidance to the whole team. 

AWS Insights Now

Get the latest AWS news and views delivered straight to your inbox

We'd love to send you Jefferson Frank’s AWS career insights and tips by email, phone or other electronic means.