How Much Does AWS Really Cost?

I used to avoid cloud hosting platforms such as AWS for a couple of reasons. One of them is pricing. Every item is priced separately, making it somewhat difficult to understand the total picture when you are beginning with AWS. Some prices can be more complex unless you understand all the AWS terms.

How Much Does It Cost To Host A Web…

Please enable JavaScript

How Much Does It Cost To Host A Website On Amazon AWS

In this article, we will take a look at the required services for a MERN stack, and how we can optimize their costs.

Photo by Taylor Vick on Unsplash

The cost calculation can be tricky. Thankfully there are tools to simplify this, which we will look into. When using AWS, you don’t know how much you will have to pay until after you get the bill. Payments are done automatically through credit cards. The thought alone is scary when you don’t know what to expect!

Having more experience with AWS, and understanding how much something typically costs makes it a lot easier. In this article we’ll go through typical prices for different kinds of AWS offerings, so you can build an idea of how much a specific architecture would cost you.

You’ll become more comfortable with the pricing the more you have experience with AWS. However, that doesn’t remove the risk of surcharges. Let’s dive in.

Understanding The Terminology

One roadblock for AWS starters is understanding all the specific naming. Do you need a reserved, on-demand, or spot instance? What about a savings plan instead?

This can make it frustrating to understand how much you’ll actually end up paying, and what you’ll need. Ideally, you should have some background on the offerings of AWS, as this will make it much easier. Nevertheless, we will go through the most commonly used services, and sum up the prices.

Do note that prices fluctuate all the time. The prices discussed here are for the eu-west-1 region in June 2021, however, every region has its own prices.

Common AWS Services Pricing

Before we continue, let’s imagine we want to implement a typical small-to-medium MERN stack. We’ll need at least the following items:

  • A MongoDB instance, or Amazon’s DynamoDB

  • A compute instance to host our back-end service, which in this case would be a NodeJS Express service

  • A place to store our static assets for our React front-end

  • A CDN (content delivery network) to have a stable speed, no matter where our user is located, and as a bonus, optimize our costs for static file storage

For the sake of this simulation, we will also assume we can pay 1 year upfront for the services.

Compute Instances: EC2 (Elastic Compute Cloud)

Photo by Florian Krumm on Unsplash

Compute instances can be tricky to summarize pricing since there are so many different types available, all with different prices. That’s why we’ll base ourselves on our MERN stack example in this case too.

Before we continue, we need to understand the different kinds of available compute instances. They come in four flavors. Reserved, spot, on-demand, and saving plan instances. If you already know the differences, feel free to skip this section.

**On-Demand EC2 Instances: **These are instances that you can turn on at any time. You will pay for the cost per hour. If you stop the instance, you don’t have to pay for the instance anymore, although you will still have to pay for its storage. This is one of the most expensive types of instances since it offers so much flexibility. If you think about it, compared to having to install a physical server, this is incredibly convenient. Your server could be running within a minute!

**Reserved EC2 Instances: Up to 75% off on-demand instances.
**These are instances that you reserve for a specific amount of time, be it 6 months, to 3 years. You can choose to have a full upfront payment or have a partial payment. Reserving for a long time, with upfront payment is a lot cheaper than regular on-demand instances.

**Spot EC2 Instances: Up to 90% off from on-demand instances.
**This instance type is more complex. It works similarly to a stock market. The more EC2 instances are being used by other people, the more expensive an EC2 instance will be. However, when fewer EC2 instances are running on AWS, the cheaper it will be. This is ideal for non-critical workloads which can be run ad-hoc, at any point in time. It can be extremely cheap, cheaper than any of the other instance types. You can set the maximum price you would like to pay, and Amazon will run a server once an instance is available for that specific price, or lower. This does mean that Amazon can start up, and terminate your service at any time. This could be used for processing services, which are okay to be run at random times. This will not work for web servers, where a 24/7 uptime is needed.

For this application example, let’s assume a T3 small fits our needs. This comes down to 107 USD yearly. Monthly that would be 8.91 USD.

Databases: DynamoDB

Photo by Tobias Fischer on Unsplash

DynamoDB, Amazon’s fully managed NoSQL database comes in two types. Provisioned, and on-demand. Similar to EC2, on-demand will be more expensive than provisioned.

In this case, the provisioned type is referring to using a predictable amount of read/writes on the database.

To give you an idea of the on-demand pricing for DynamoDB:

Write requests: $1.4135 per million write request
Read requests: $0.283 per million read request

You’ll also have to pay for the actual database storage, on top of the requests. The first 25 GB stored per month is free. You’ll have to pay $0.283 per extra GB-Month.

Furthermore, there are more pricing options for back-ups and so on.

A quick simulation, if we have 3.5 million writes, and 3.5 million reads on a 20GB database, this would total to around 5.33 USD per month.

Databases: MongoDB

There is a fully-managed MongoDB solution available for AWS as well, called MongoDB Atlas. According to their pricing page, a MongoDB instance with 2GB of RAM would cost around 57 USD per month, although a cheaper instance might also fit your needs.

Static File Storage: S3 (Simple Storage Service)

Photo by Maarten van den Heuvel on Unsplash

The pricing of Amazon’s static file storage for basic situations is quite easy. If however, you would like to save money and optimize your costs, this can get a bit more complex. The specific pricing type can be set up per specific files.

S3 Standard: This is the standard pricing for data, which will be replicated in several zones across the AWS service in case of failure. This is recommended for standard, and actively used files.

**S3 Infrequent Access (IA): **With this pricing class, the storage cost of the files is cheap, however, the retrieval of the file is more costly. This is ideal for lesser-used files. The files will still be replicated across different zones for redundancy. Retrieving files is still fast.

**S3 Glacier: **This is similar to S3 IA, but with even cheaper storage prices, and more expensive retrieve rates. This is perfect for archiving files, for example for legal obligations to keep specific files. File retrieval is slower, from minutes to hours.

**S3 Deep Archive: **Similar to S3 Glacier, but cheaper, and with a slower retrieval, typically in hours.

S3 Intelligent Tiering: This tier lets AWS select the most appropriate tier for your files automatically, in an attempt to optimize costs. This does come with an extra storage monitoring fee.

Let’s take a 1 GB S3 storage as an example here. For our React application, this should not exceed 1 GB. Amazon’s current price for S3 Standard is $0.023 per GB per month. Furthermore, there is an operation cost on the S3 files of $0.005 per 1000 operations.

If we have 1GB of data, with 3 million requests per month, that would cost us about 15 USD. However, by adding a CDN in front of our S3 storage, we can significantly reduce the S3 retrieval costs, as the frequently accessed files will be cached in the CDN and will not have to be retrieved multiple times.

With the setup of a CDN on top of our S3 bucket, the S3 bucket itself should cost us a few dollars at most for our MERN stack.

Content Distribution Network: CloudFront

Next up, we’ll want to set up a content distribution network to sit in front of static files, such as React applications and assets.

The CDN provided by AWS is called CloudFront. Depending on the regions you set up CloudFront to be active in, different pricing kicks in. Let’s go with the worst case of 0.12 USD per GB out. Next is a pricing per 10,000 requests, worst case this is 0.022 USD. For 1 million requests, this would come down to 2.2 USD for the request costs. Regarding GB out, let’s assume 20GB, this would come down to 2.4 USD.

There is an extra cost as well for invalidations when you would like to invalidate the cache on demand. The first 1,000 invalidation requests per month are free of charge. For our small application, this is more than enough.

This would come down to **4.6 USD per month **for our CDN.

Prices Summary For Our MERN Stack

The full price breakdown per month:

  • Compute: EC2 (reserved): 8.91 USD

  • Static files: Standard S3: 2 USD

  • Database: DynamoDB: 5.3 USD

  • CDN: CloudFront: 4.6 USD

  • Total: 20.81 USD

This is the price of a very stable setup, for an application that would be in use. For smaller applications, you can certainly get away with cheaper setups. A T3.nano EC2 instance is usually enough to get started, which is 3x cheaper, at only 2.25 USD per month. This would bring the total down to 14.15 USD. When starting, other costs such as static files, database, and CDN will also be lower.

Please note, this calculation is purely an estimation with the available prices at the time of writing this article, and not a guarantee. For your use cases, please use the below calculation tools which we will introduce.

Calculation Tools

Now we have an idea of the different options for a MERN stack on AWS. A more accurate estimation of your costs is always a good thing. There exists a few tools to map out your requested architecture and estimate the prices.

The official tool from AWS is the AWS Calculator. Other websites offer similar estimations while being able to draw your architecture, such as CloudCraft, they have a beautiful tool to create 3D and 2D architecture diagrams. As a bonus, a price estimation is given while mapping out the architecture.

Billing and Tagging Services

Finally, you will want to know where your money is going on the AWS platform. To do this, most AWS services can have a specific tag added to them. We can create a tag project and assign it our project name. This way, when using the AWS Cost Explorer, you will be able to see a price breakdown per service, per project. It is a very recommended practice to properly tag your AWS resources.

Summary

A stable setup for a MERN stack could cost around 20 USD per month, however, when you are starting a project, a much cheaper setup will do just fine. The benefit of cloud hosting is the ease of auto-scaling its services. In case your current service cannot handle the load, you can configure it to automatically spin up extra instances.

Before the start of your project, it’s a great idea to map out your architecture and estimate its cost using tools such as the AWS calculator, or CloudCraft.

Further Reading

AWS has its own page on cost optimization, which I recommend to have a read-through.
AWS Cloud Financial Management | Optimize and save your IT costs

I also recommend reading Nutanix’s article on optimizing EC2 costs, as it is very clear and goes into much detail. EC2 is a very important service in AWS’s offer.
AWS EC2 Pricing and Best Practices: The Complete Factsheet on Price Reduction and Cost Optimization